09-12-2009 01:42 PM
Dear All,
I try to change the href dynamically using javascript as following. (I try it in Firefox. It runs properly.)
<SCRIPT language="JavaScript">
function changeLink(link, str1, id)
{
document.getElementById(link).href=str1.toString() + document.getElementById(id).value;
}
</SCRIPT>
<a href="#" onclick="changeLink('abc', 'http://www.google.com/search?q=', 'key');" id="abc">Search</a><br />
<input type="text" id="key" value="love">
However, when I click it, there is nothing happen. (I expected that it can go to the page immediately.)
Thanks.
Best Regards,
Ricky Siu
09-13-2009 08:46 AM
Hi Ricky,
What version of the BlackBerry operating system are you running?
09-13-2009 10:06 AM
Dear Tim,
I am using JDE 4.7. However, I forgot to say that the html page is rendered in Browser Field instead of the BlackBerry Internet Browser.
Thanks.
Best Regards,
Ricky Siu
09-13-2009 12:52 PM
Ah.. that's your problem right there.
4.7 BrowserField still uses the old 4.5 browser rendering and JavaScript engine. So it doesn't really support DHTML and/or many JavaScript capabilities.
For the full lowdown on BrowserField I have referenced another thread where I explain the differences.
http://supportforums.blackberry.com/rim/board/mess
09-13-2009 08:28 PM
Thanks, Tim.
Is there any way to change the href attribute according to the input text field using Browser Field?
09-13-2009 09:25 PM
Well.... with BrowserField you must fetch all the resources yourself via Java code for the URL selected in BrowserField. So you could do some logic in your Java code to detect that your user was on a certain page and then re-route the URL to the one you desire. This could get tricky based on how complex your logic is on your web page that wants to change the URL.
But I can't think of any way off the top of my head of doing it in JavaScript within the HTML content.
09-14-2009 01:26 AM
I use the Browser Field to read local HTML file. Thus, I cannot use the server code to dynamically generate the page. In fact, the link should be change according to the input text.
Thanks.