Solved

javascript window transfer

Posted on 2001-08-14
13
837 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
  • 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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 …

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now