Forum Moderators: open

Message Too Old, No Replies

This Window is a Pane!

How can I make a link that includes the page and the javascript?

         

BaseVinyl

11:44 pm on Jun 1, 2004 (gmt 0)

10+ Year Member



Hello js pros of all ages and sizes!

I have a question for you and any help would be appreciated.

I have a webpage (these are examples only):
[widgetname.com...]
and on that page are several clickable links that open js windows with content.
eg:
javascript:jsOpenWnd (372,'widgetname','widgetname2')

Is there a way I can make a link from another page, eg:
[widgetname2.com...] that will go to the javascript window content from the first page?

I don't want the link to have to go back to the first page and then have the user click on a link just to open the js window, can I combine the two into one link?

Any help would be appreciated and if this request isn't too clear then, well...you should see my desk!

Thanks
BaseVinyl

Rambo Tribble

2:53 am on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For security reasons, a parent window can access its offspring and the offspring can access the parent, but a separately spawned window can have access to neither. One child can, however, access another child of the same parent by going through the parent.

If that isn't confusing enough, I'll be happy to obfuscate it more.

BaseVinyl

3:10 am on Jun 2, 2004 (gmt 0)

10+ Year Member



Wow! So it seems harder than i thought hard could be?

Thanks for answering!

So can I create a link from one page to another page that has a js window open only link and make it open properly from a separate page?

Thanks ever so much!

BaseVinyl

Rambo Tribble

2:31 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, I realize that I over-generalized the similarity between frames and windows. Separate windows cannot use the parent-child relationship as I described, only frames within a window can.

Rambo Tribble

3:27 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On further reflection, I realize that it is the object identifier "opener" that you will want to use. A child window can make calls to the parent with the opener in the dot notation chain. Save the following two documents as separate files, then open the first, click on its body and a window will appear. Click on the window's body and it will return the value of a variable in the parent window.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Parent Demo File</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body{height:100%;}
</style>
<script type="text/javascript">
var v="4";
function mkWin(){
winOne=window.open("child_file_name.htm","windOne","height=300px,width=400px,left=200px,top=200px");
}
</script>
</head>
<body onclick="mkWin();">
</body>
</html>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Child Demo File</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body{height:100%}
</style>
<script type="text/javascript">
function ckVar(){
alert(opener.v);
}
</script>
</head>
<body onclick="ckVar();">

</body>
</html>

[edited by: Rambo_Tribble at 3:31 pm (utc) on June 2, 2004]

BaseVinyl

3:30 pm on Jun 2, 2004 (gmt 0)

10+ Year Member



Thanks RT!

I have no idea what it all means but I'll give it a shot!

Base

Rambo Tribble

3:53 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's another example that may be closer to what you are looking for:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Fun with windows</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body{height:100%;}
</style>
<script type="text/javascript">
function opWin(){
winOne=window.open("","winOne","height=200px,width=300px,left=100px,top=200px");
winTwo=window.open("","winTwo","height=200px,width=300px,left=300px,top=300px");
winOne.document.write('<html><head><title></title><style text/css>html,body{height:100%}</style>'+
'</head><body id="pgBod"></body></html>');
winOne.document.close();
winTwo.document.write('<html><head><title></title><style text/css>html,body{height:100%}</style>'+
'<scr'+'ipt type="text/javascript">'+
'function changeOne(){opener.winOne.document.getElementById("pgBod").style.background="#DEE";}'+
'</scr'+'ipt></head><body id="pgBod" onclick="changeOne();"></body></html>');
winTwo.document.close();
}
</script>
</head>
<body onclick="opWin();">
</body>
</html>

BaseVinyl

3:59 pm on Jun 2, 2004 (gmt 0)

10+ Year Member



WOW RT! This is blowing my mind!

Ok...so if this is what I may be looking for which variables would I change to make this script correspond to the pages I wish to work the magic on?

Thanks...as you can tell...I'm fresh off the turnip truck on this one!
:)

Rambo Tribble

4:15 pm on Jun 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have to go to work, so if no one has helped you by this evening, I'll get back to you.