Skip to content Skip to sidebar Skip to footer

Javascript Location.replace And Iframe

Following program can work in chrome, but in the firefox not work, I need to refresh the page, otherwise the page will be blank! The firefox will jump out of the store window to us

Solution 1:

If you use jQuery, you can use something like $('#saveFrame').attr('src', url). It should work for all browsers.

Solution 2:

try

document.getElementById('SaveFrame').src="http://google.com/";

Solution 3:

Addressing an element via a variable which is implicitely created in the global scope is a proprietary "Internet Explorer" way that is most likely to going not work in other browsers (although Chrome supports this due to compatability reasons). You should always address an element through a Dom Selection Method either via:

document.querySelector(id)
// ordocument.getElementById(id)

For your case that would be:

document.getElementId('SaveFrame').contentDocument.location.replace(url);
// ordocument.getElementId('SaveFrame').src= url;

Solution 4:

This should work and it is fast loading for the webpage It worked for me...

onmouseover="window.open ('http://www.yourpage.com','YourTargetName'); this.onmouseover=null;"

The code "this.onmouseover=null;" means that it should only do it ONCE when it loads and not repeat the the attribute on a second mouse over, if you want it to repeat the attribute on a second mouse over then delete the "this.onmouseover=null;" from the code and make it look like this to load each time mouse is over:

onmouseover="window.open ('http://www.yourpage.com','YourTargetName');"

EXAMPLE:

<ahref="#"onmouseover="window.open ('http://www.yourpage.com','YourTargetName');">
My Link</a>

Or try this:

OnClick="window.open ('http://www.yourpage.com','YourTargetName');"

EXAMPLE:

<ahref="#"OnClick="window.open ('http://www.yourpage.com','YourTargetName');">
My Link</a>

or

<ahref="javascript:window.open ('http://www.yourpage.com','YourTargetName');">
My Link</a>

or

If you wish to use window.location.replace to not update the history when loading the page or the frame, use links that look like this:

<ahref="#"onclick="YourTargetName.location.replace ('http://www.YourPage.com');">
The targeted Link</a>

or

<ahref="javascript:YourTargetName.location.replace ('http://www.YourPage.com');">
The targeted Link</a>

information: For this script all onclick, onmouseover, onmouseout , onload and href="javascript:" will work.

NOTE: Keep in mind that the iframe has to have the name="YourTargetName", for example to look something like this:

<iframe id="SaveFrame" style="display: none" name="YourTargetName"></iframe>

Information: The difference between window.open and window.location.replace or YourTargetName.location.replace is that: - window.open loads in the browser history. - window.location.replace or YourTargetName.location.replace does not load history.

Post a Comment for "Javascript Location.replace And Iframe"