Solved

javascript window transfer

Posted on 2001-08-14
13
840 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
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.

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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
Obtaining data on ASP 8 30
Asp in server side with Mssql Server 7 4 28
Need HTML output in powershell line by line 3 30
Non-Resizable Pharagraph 2 8
Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

828 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