Gossamer Forum
Home : General : Internet Technologies :

Guys.. A simple Javascript Question... : )

Quote Reply
Guys.. A simple Javascript Question... : )
Hehe.. I just wanna ask a simple javascript question.

I know this is Links discussion only... but so many ppl here... Smile



Anywayz...

Anyone knows if there is a way to detect the parent document's

href (url) from a popup window opened by the parent window?



That is, if I have a HTML file named Mother.html and it uses a

Window.open command to open Child.html.

Would it be possilbe for the Child.html to detect the URL of Mother.html

using Javascript? or any other ways? It seems the Document.referrer

and the parent.document.href variables in Child.html are Undefined...



Hehe Thx alot first... Please tell me a simple answer Yes or No...



Regards...! John Crazy


============
Enjoy Your Day!
============
SponsorPlus.NET
============
Quote Reply
Re: [spnet] Guys.. A simple Javascript Question... : ) In reply to
opener is the object.

i know opener.name gets the name of the frame/window it was opened from..

try opener.href

--
jsu
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
nah.... unable to get the url...

opener.name does seem to have a value cuz it prints a blank

rather than "undefined"..



not even opener.document.href...



does that mean there is no way?!


============
Enjoy Your Day!
============
SponsorPlus.NET
============
Quote Reply
Re: [spnet] Guys.. A simple Javascript Question... : ) In reply to
I have a feeling there isn't. Also, from what I have learned using the opener object.. if the page opened in the popup is not on the same server as the opener, then it won't display much information about the opener itself. I used opener awhile ago in a script to detect when an opener is in focus and when it goes out of focus. You can also tell if its closed with opener.closed..

you can try..

window.opener.document.location or
window.opener.document.location.href

appears to be something, but i didn't look much into it.

--
jsu
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
Wow...

window.opener.document.location.href Worked

I can see the openr's url. But as you predicted it shows

an access denied message if the domains are different.



Thanks alot for the tips for this Opener object Jerry... Smile


============
Enjoy Your Day!
============
SponsorPlus.NET
============
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
Thanks, Jerry...I'll have to pass those codes along to a co-worker of mine whose been having the same problem with a script she is writing.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] Guys.. A simple Javascript Question... : ) In reply to
Nice. Two birds with one stone.

Glad it worked for you spnet.

--
jsu
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
Hm.. how about this one.

I've got a web page framed to mask the url of a web site on a non-standard port (ie... foo..com:1010). I need to be able to set the document title for the framed page differently for each page so as to not make it less obvious. I don't have access to the frame source since it's done dynamicly by DNS2GO.

(I can't remember exactly what I used now...)

something like:

top.document.title = "something"

worked, except if the index page (with the frame codes) had a real title in it (either set via html or javascript. In this case I was getting a permissioned denied error. what gives??


OR

is there a way to fool the browser to hide the port number in the address bar?

--Philip
Links 2.0 moderator
Quote Reply
Re: [sponge] Guys.. A simple Javascript Question... : ) In reply to
GT needs to make a javascript forum in the general section. I soooo want a javascript forum. However, not that many people would use it. I like javascript though. It's really useful. This advanced browser thing is a good example of some hardcore javascript.

Anyways.. to answer your question.. in the javascript document object model.. children are not allowed to edit things set by their parents. it's possible however for a child to contact a parent function.

is the html for the frames editable by you? if so.. try something along the lines of this..

Code:
<script>
<!--
function changeTitle (t) {
document.title = t;
}
//-->

inside of the main html with the frame code.

and..

inside each of the pages.. you'd do something like this..

Code:
<script>
<!--
if (self.parent)
if (document.title) self.parent.changeTitle (document.title);
//-->

and to set the titles.. it'll use the titles in the actual html files.. not sure if that'll work.. i'll do some tests.. it'll take awhile to create a bunch of html files

--
jsu
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
http://www.jsu07.com/ladila.html

nope.. it works great if they are on the same server (didn't test port, but i'm guessing it'll count as another server). but same permission denied on different servers.

so i guess children can't access parent functions either. the if (self.parent) does evaluate to true tho.. so they can see them.. but they can't touch them. it's just microsofts security. i remember i tried to talk directly to the geocities javascript one time on a geocities accoutn i created, somehow i was able to do it.. even tho they have a different ad server.. i just told it to close itself. but iduno.. maybe you can try mirroring or aliasing a site.


[edit] i have another idea tho.. i'll test it before posting it.

--
jsu

Last edited by:

Seto Kaiba: Aug 1, 2002, 3:15 AM
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
if you try it now.. it works.. but it's such ugly code. i hid a frame underneath that stays at www.jsu07.com and it is passed the document's title.

i'm going to try one last thing

[edit] nope.. my last idea gets the same error also.. i thought maybe.. i'd get the parent to get the child information.. but apparantly.. if its on another server.. it won't allow it either.. it's very little code though. only on the frame page. no need for code anywhere else.

the problem with the method that actually worked is.. i don't like it.. it uses a second frame to open a page on the original server. this makes it so you have to press back twice everytime you want to go back. and even though it uses a small cgi file.. there is a bit of load time.

--
jsu

Last edited by:

Seto Kaiba: Aug 1, 2002, 3:54 AM
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
OH geez. :P

Ok.. i don't use netscape or any of those other browsers.. but here's a solution for IE Explorer..

http://www.jsu07.com/new2.html

works fine.. i just took that concept that worked with the pressing back problem and used an iframe instead.

i know iframes don't work in netscape.. but since netscape is netscape and IE is IE.. i bet theres a way to do it in netscape as well.. i am just not willing to download the browser.

--
jsu
Quote Reply
Re: [Seto Kaiba] Guys.. A simple Javascript Question... : ) In reply to
Not really anything to do with Links 2...so I'm moving to Internet Technologies ;)

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Guys.. A simple Javascript Question... : ) In reply to
The other half of this thread is locked in chat-chat lol

Slice and dice.