PDA

View Full Version : iframe in internet explorer not working



kimberlyhello
04-09-2007, 02:42 AM
Hi,

I have an iframe that loads multiple pages depending on what the user types into a text box. It works fine in firefox, but not in internet explorer(6 and 7)

Here is the javascript code:

window.onload = function () {
if(document.forms["searchbox_006388034472510427843:pil-s7xg5oy"].q.value.toLowerCase() == "google"){
window.open("http://www.google.com", "site")}

Here is the iframe:

<iframe src="http://www.yahoo.com" width="95%" height="95%" align="top" name="site" id="site"></iframe>


Does anyone see a problem...I don't. Is it a problem with iexplorer? Maybe there is some kind of script I can use for people with browsers other than Firefox.

Thanks in advance to anyone that can help.

jscheuer1
04-09-2007, 03:47 AM
Should be:


window.onload = function () {
if(document.forms["searchbox_006388034472510427843:pil-s7xg5oy"].q.value.toLowerCase() == "google"){
window.open("http://www.google.com", "site")}
}

And, you don't need the id for the iframe tag, name is sufficient:


<iframe src="http://www.yahoo.com" width="95%" height="95%" align="top" name="site"></iframe>

Your form should look something like so (names, not id's should be used):


<form action="#" name="searchbox_006388034472510427843:pil-s7xg5oy">
<input type="text" name="q" value="Google">
</form>

If all that checks out, the only thing that I can think of is that:


document.forms["searchbox_006388034472510427843:pil-s7xg5oy"].q.value.toLowerCase() == "google"

tests as false for some reason but, that has nothing to do with the code you have shown.

kimberlyhello
04-09-2007, 06:45 AM
for helping me.