Link to home
Start Free TrialLog in
Avatar of kaarsenmaker
kaarsenmaker

asked on

javascript window transfer

I have an iframe sitting on a page. when I click on a link I would like the information about the url of the iframe to be passed along with the page info. is there javascript that can accomplish that?

something like this:

function processForm(theForm, theURL, windowName, features) {
    var dest = "";
    var newURL = theURL;

    dest = document.ratesform.destination[document.ratesform.destination.selectedIndex].value;
    newURL = theURL + "?destination=" + escape(dest);
    window.open(newURL, windowName, features);
    return false;
}
Avatar of avner
avner

Like this ? :

function processForm(theForm, theURL, windowName, features) {
   var dest = "";
   var newURL = theURL;

   dest = document.ratesform.destination[document.ratesform.destination.selectedIndex].value;
   newURL = theURL + "?destination=" + escape(dest)+"&URL="+theURL;
   window.open(newURL, windowName, features);
   return false;
}

notice the added URL value pair
Avatar of kaarsenmaker

ASKER

from outside the iframe I need to get the URL of the iframe and pass it through as a parameter. This example is similar to what I want to but it doesnt show me how to get the url of the contents of the iframe.
To get the URL of the contents of the IFrame just use :

document.all.iframeid.src

for example:

<BODY onload="alert(document.all.moshe.src)">

<IFRAME id="moshe" src="http://www.yahoo.com"></IFRAME>
this is what I have on my page, it pops up a window on IE both on the MAc and PC, but it will not work on Netscape, why?


<script language="JavaScript">

<!--
function processForm() {
    var dest = document.all.causes_iframe.src;
    alert(dest);
    return false;
}
//-->
</script>
document.all dosen;t work in NS.
IFRAME also won't work in Netscape.

You should try and use ILAYER instead for NS. But you are getting into a complicated CrossBrowsers issue.
iframes work in Netscape 6, this pop up doesnt work in Netscape 6. is there something like document.all that does work in netscape and IE?
Oh ... I thought you were talking about NS4.x.

Please ignore the previous comment.

Anyway , to do this in NS6 try :

document.getElementById("causes_iframe").src
that one didnt work either:

<script language="JavaScript">

<!--
function processForm() {
    var dest = document.getElementById("causes_iframe").src;
    alert(dest);
    return false;
}
//-->
</script>
this last solution doesnt work in IE either, the other one worked in IE
ASKER CERTIFIED SOLUTION
Avatar of avner
avner

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
you the man avner,

I was missing the id tag on the iframe. I am increasing your point total to 400 because you were so patient and you hit the nail right on the head. go ask your boss for a raise cause you are most defintiely on your game today.
sorry the module would only allow me to increase to 300
kaarsenmaker ,
Thank you .
This is the kind of comments that inject the fuel to helping other developers.
Always happy to help.