SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    Say WHA?! goober's Avatar
    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!
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  2. #2
    I believe you have my stapler. scrubz's Avatar
    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 17:24.

  3. #3
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks!

    From the looks of this code, it should work like a charm.

    Thanks again!
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  4. #4
    Say WHA?! goober's Avatar
    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>
    And this is the code I have for the link:
    Code:
    <a href="http://www.site.com" onClick="JavaScript:OpenWindow1()">
    Any ideas? Any help would be greatly appreciated. I can't believe I've forgotten how to do this simple stuff in such a short time.

    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!
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  5. #5
    I believe you have my stapler. scrubz's Avatar
    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?

  6. #6
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Scrubz, you're making sense now.

    By the way, disregard the PM i sent you..i probably sent it the same second you replied to this!
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  7. #7
    Say WHA?! goober's Avatar
    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()">
    This is the code that i put inside of the link where, after opening the page, I want the small window to pop up with the back link...I get 'object expected' When it's clicked on. Any advice?

    Thanks.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  8. #8
    I believe you have my stapler. scrubz's Avatar
    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.

  9. #9
    Say WHA?! goober's Avatar
    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!
    Last edited by goober; Apr 17, 2001 at 10:15.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  10. #10
    I believe you have my stapler. scrubz's Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •