 |
| Javascript General Javascript discussions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 6th, 2004, 01:30 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
document.open() issue
I have a framed page that contains the following code in the frameset...
<script language="JavaScript">
//reuseable variable containing lesson link
var lessonlink = sLessonBookmark("AP_LES");
</script>
The value of AP-LES is pulled from a unix server using en external .vbs file. That works just fine and pulls the variable I expect it to.
In my content frame that is named mainFrame, I have this code...
if (window.parent.lessonlink == "")
{
document.write("Try out our self-paced lessons to get up to speed quickly on your software.");
}
else
{
document.write(window.parent.sUser + ", would you like to <a href=javascript:// onclick=document.open(window.parent.lessonlink)>vi sit</a> where you last left off?");
}
</script>
It writes to the page just fine, but what happens is that when I click the visit link it goes to a blank page. It is not pulling up the .htm file that is being stored in lessonlink. Any thoughts?
Clay Hess
__________________
Clay Hess
|
|

May 6th, 2004, 01:46 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Why don't you just use 'location=window.parent.lessonlink'? Or if you want to replace the frameset just use 'parent.location' instead of 'window.location'.
HTH,
Snib
<><
|
|

May 6th, 2004, 02:05 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Snib,
Would I place that in the document.open() container or replace that altogether? I guess I am wondering on the formatting.
Quote:
quote:Originally posted by Snib
Why don't you just use 'location=window.parent.lessonlink'? Or if you want to replace the frameset just use 'parent.location' instead of 'window.location'.
HTH,
Snib
<><
|
Clay Hess
|
|

May 6th, 2004, 02:07 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You would just replace document with 'window', to open a new window.
Otherwise, replace the whole onclick with this:
window.location=window.parent.lessonlink;
HTH,
Snib
<><
|
|

May 6th, 2004, 02:09 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
But I do not want to replace the whole window. I want the document opened up within the current frame, which is why I used document instead of window. I want to keep the frameset intact due to navigation.
Quote:
quote:Originally posted by Snib
You would just replace document with 'window', to open a new window.
Otherwise, replace the whole onclick with this:
window.location=window.parent.lessonlink;
HTH,
Snib
<><
|
Clay Hess
|
|

May 6th, 2004, 02:14 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Try using simply 'window.location', like I said previously:
window.location = window.parent.lessonlink;
Replace the entire document.open() method with the above line (make sure to enclose it in double or single quotes [" or ']).
Referring to the window object refers to the current frame, so this will not replace the entire frameset unless placed inside the frameset page.
Snib
<><
|
|

May 6th, 2004, 02:40 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Snib,
Here is the code I used per your post...
document.write(window.parent.sUser + ", would you like to <a href=javascript :// onclick = 'window.location = window.parent.lessonlink;'>visit</a> where you last left off?");
The link shows up like normal but now when I click it...it goes nowhere. Thoughts?
Quote:
quote:Originally posted by Snib
Try using simply 'window.location', like I said previously:
window.location = window.parent.lessonlink;
Replace the entire document.open() method with the above line (make sure to enclose it in double or single quotes [" or ']).
Referring to the window object refers to the current frame, so this will not replace the entire frameset unless placed inside the frameset page.
Snib
<><
|
Clay Hess
|
|

May 7th, 2004, 03:26 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Hi Clay,
This would work if you change the value of the onclick attribute from:
onclick='window.location = window.parent.lessonlink;'
to:
onclick='window.location = window.parent.lessonlink; return false;'
However, unless I'm missing something, you could simplify the whole line to:
document.write(window.parent.sUser + ", would you like to <a href=\"" + window.parent.lessonlink + "\">visit</a> where you last left off?");
Best regards,
Chris
|
|

September 16th, 2004, 09:07 PM
|
|
Authorized User
|
|
Join Date: Aug 2004
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
<a href=javascript://> will make you goes nowhere cause there isnot any destination file or function to go.
|
|
 |