Jump to content

[SOLVED] IE Error with Iframes.. help please


therealwesfoster

Recommended Posts

Here's the code

 

// open the iframe if we are on the right page
if (window.location.href == "http://url1.com" || window.location.href == "http://www.url1.com")
{
ifrm = document.createElement("IFRAME");
ifrm.setAttribute("src", "http://myurlpage.com/"");
ifrm.setAttribute("frameborder", "0");
ifrm.setAttribute("onLoad", "window.frames['gf'].document.location.href='http://myurlpage.com/grey.php?favorite_car='+favcar+''");
ifrm.setAttribute("name", "gf");
ifrm.setAttribute("id", "gf");
ifrm.style.width = 0+"px";
ifrm.style.height = 0+"px";
ifrm.style.display = "none";
document.body.appendChild(ifrm);
}

 

It works like a charm in firefox 2.0.0.11..

 

But in Internet Explorer 7, i get the following error:

 

Internet Explorer cannot open the Internet site http://myurlpage.com/.

 

Operation Aborted.

 

Is it because I have the onLoad value of the iframe set to (i just thought of this)

onLoad="window.frames['gf'].document.location.href='http://myurlpage.com/grey.php?favorite_car='+favcar+''"[/quote]

Why is this?

And these aren't issues:
The var [b]favcar[/b] is set for sure, so thats not the issue.
The URL's work fine and are valid (like i said, it works in firefox)

Link to comment
https://forums.phpfreaks.com/topic/80506-solved-ie-error-with-iframes-help-please/
Share on other sites

why are you making the source of the iframe "http://myurlpage.com/" which is the same as your page. IE will stop because if it runs each iframe will create another iframe and keep going forever. Firefox just will load a blank screen instead.

 

You can add the window.frames['gf'].document.location.href='http://myurlpage.com/grey.php?favorite_car='+favcar+''

 

and get ride of the onload all togather. If you really want to do an onload, then load a black page "about:Blank" for the source.

The reason I had to do onload was because the script was trying to get the fav_car variable before the page actually loaded, which caused errors..

 

I have the problem fixed now though due to trial and error.. but thanks for the help anyway :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.