Solved

javascript window transfer

Posted on 2001-08-14
13
841 Views
Last Modified: 2008-03-03
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;
}
0
Comment
Question by:kaarsenmaker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 14

Expert Comment

by:avner
ID: 6385475
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
0
 

Author Comment

by:kaarsenmaker
ID: 6385523
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.
0
 
LVL 14

Expert Comment

by:avner
ID: 6385531
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>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kaarsenmaker
ID: 6385681
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>
0
 
LVL 14

Expert Comment

by:avner
ID: 6385687
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.
0
 

Author Comment

by:kaarsenmaker
ID: 6385699
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?
0
 
LVL 14

Expert Comment

by:avner
ID: 6385724
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
0
 

Author Comment

by:kaarsenmaker
ID: 6385746
that one didnt work either:

<script language="JavaScript">

<!--
function processForm() {
    var dest = document.getElementById("causes_iframe").src;
    alert(dest);
    return false;
}
//-->
</script>
0
 

Author Comment

by:kaarsenmaker
ID: 6385788
this last solution doesnt work in IE either, the other one worked in IE
0
 
LVL 14

Accepted Solution

by:
avner earned 300 total points
ID: 6385805
This works in both IE5 and NS 6 :

<script language="JavaScript">
<!--
function processForm() {
   var dest=document.getElementById("causes_iframe").src
   alert(dest);
   return false;
}
//-->
</script>
<iframe src="http://www.yahoo.com" name="causes_iframe" id="causes_iframe"></iframe>

<script>setTimeout("processForm()",1000)</script>
0
 

Author Comment

by:kaarsenmaker
ID: 6385849
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.
0
 

Author Comment

by:kaarsenmaker
ID: 6385899
sorry the module would only allow me to increase to 300
0
 
LVL 14

Expert Comment

by:avner
ID: 6385958
kaarsenmaker ,
Thank you .
This is the kind of comments that inject the fuel to helping other developers.
Always happy to help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Technology Resume 7 88
Obsolete font tag need to convert to CSS 3 54
Boolean 13 49
Scroll 5 news at a time using vticker 2 39
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question