SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: Redirecting the Parent window
-
Apr 15, 2001, 16:28 #1
- Join Date
- Sep 2000
- Location
- United States
- Posts
- 1,921
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hello,
It's been a while and I currently don't have access to my old JavaScript tutorials, so please bear with me.
I'm aiming to, when somene clicks a link on my site (which redirects to another 3rd-party site), pop up a window which gives the option to return to my site. When the link is clicked inside this small pop-up window, I want the parent window to be redirected back to the main page of my site.
Any help would be greatly appreciated.
Thanks in advance!
-
Apr 15, 2001, 18:21 #2
- Join Date
- Feb 2001
- Location
- Van down by the river
- Posts
- 254
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Use a link in your child window like so:
<a href="javascript://" onClick="window.opener.location.href='my_page.html'">Back to main</a>
If you also want the parent window to come to the front and the child window to close, do this:
<a href="javascript://" onClick="window.opener.location.href='my_page.html';window.opener.focus();window.close();">Back to main</a>
Note: The above links should be with javascript as one word. (SitePoint edits them, thus the split).Last edited by scrubz; Apr 15, 2001 at 18:24.
-
Apr 16, 2001, 08:58 #3
-
Apr 16, 2001, 09:21 #4
- Join Date
- Sep 2000
- Location
- United States
- Posts
- 1,921
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
edited for spelling
okay, Scrubz:
The problem I have is not with your code, but rather code I'm using to open my Pop-up window. In conjunction with your code, this is the script I have between my <HEAD> tags:Code:<SCRIPT LANGUAGE="JavaScript"> function openWindow1 { var popupWin = null; popupWin = window.open('http://www.interfall.com/Franklin/BackToMain.html','BackToMain','width=400,height=375,resizable=no,menubar=no,toolbar=no,left=10,top=10,scrollbars=yes') popupWin.opener.name="Main"; popupWin.focus(); } </SCRIPT>
Code:<a href="http://www.site.com" onClick="JavaScript:OpenWindow1()">
BTW, the exact error I'm getting is an 'object expected' error.
Remember, all the "java scripts" really are one word in my code.
Thanks again!
-
Apr 16, 2001, 18:36 #5
- Join Date
- Feb 2001
- Location
- Van down by the river
- Posts
- 254
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Is the code you posted from the popup window? From your original post, it sounded like you wanted to open a popup window containing a link back to your site, and when it's clicked, your page comes back in the parent window.
If the code below is in a popup, your link is trying to open another popup window (or load your site in the existing popup with the same name).
In your onClick, just use...
onClick="window.opener.location.href='http://www.interfall.com/Franklin/BackToMain.html'"
The object expected error is probably from missing () after your function name:
function openWindow1() {
But you shouldn't need that function in the popup. Have I totally confused anyone yet?
-
Apr 16, 2001, 18:41 #6
-
Apr 16, 2001, 18:50 #7
- Join Date
- Sep 2000
- Location
- United States
- Posts
- 1,921
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
well, I have the logic right. I double-checked to make sure.
Here's what happens. I click on the link, and that's when i get the object expected:Code:<a href="http://www.site.com/" onClick="JavaScript:OpenWindow1()">
Thanks.
-
Apr 17, 2001, 06:52 #8
- Join Date
- Feb 2001
- Location
- Van down by the river
- Posts
- 254
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Two problems:
1) Put parenthesis after your function name:
You have: function openWindow1 {
It should be: function openWindow1() {
2) When calling the function with your onClick, you've spelled the function OpenWindow1, but it should be openWindow1 (lower case o).
That should do it.
-
Apr 17, 2001, 11:02 #9
- Join Date
- Sep 2000
- Location
- United States
- Posts
- 1,921
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks!
Perfect!!
I forgot about small capitalization errors with JavaScript.
If you want to check out what you've helped to complete, simply go to:
http://www.interfall.com/Franklin/index.asp
and click on the Weather picture. You'll see the window pop-up when it's clicked on.
Well, I'm off to monkey around to get the proper size for the window...thanks again! You've made my day!
-
Apr 17, 2001, 11:35 #10
- Join Date
- Feb 2001
- Location
- Van down by the river
- Posts
- 254
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Bingo! Cool, it looks like it's working.
Bookmarks