SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Execute 2 links in same window with 1 click

    Hello,

    I have a problem, I want to execute 2 things when I click on 1 link, details below.

    When I click in my download section on a file, I want that the downlaod start then I get redirected to another link in the same window (not a pop-up)...

    For the download, I can use the <a href="address of the file">
    but I need to add something like OnClick="..." to be able to get to the new page?

    There will probably be a delay between the two operations, but that would be great if both operations could be done at the same time...

    Thanks in advance.
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  2. #2
    SitePoint Zealot Saj's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    Code:
    <a href="file.exe" onclick="window.location='newpage.html'">Download this file</a>

  3. #3
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but the code you gave me, ain't working...
    Tell me if you got any other idea... I think that we need a delay between the two operations... That would require the cookies I think, since we leave the page to get to the other one, then the download start after the time get over. I'm probably wrong too hehe

    Thanks in advance.
    Last edited by HeadSpin; Jun 7, 2003 at 16:11.
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  4. #4
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the best way I can think to do it.

    Code:
    <a href="file.exe" onclick="window.open(this.href, '_blank'); window.location.href="test.php"; return false;">Click here</a>
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  5. #5
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but both codes doesn't work... I think that the code must be more complex then those.

    Thanks in advance.
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  6. #6
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well mine obviously opens a new window, which will display the download prompt, and then the current window goes to a new page, it works in Mozilla and IE and Opera here... not sure what else you want...
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  7. #7
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you just said what I wanted but it doesn't work for me... that's weird... the <a href="file.exe" part work, because the download start BUT the pop-up doesnt appear ....

    <a href="test.php" onclick="window.open(this.href, '_blank'); window.location.href="file.exe"; return false;">Click here</a>

    it's not supposed to be like that, if you want the download in a pop-up and the main page going to the new page?

    And when I click, the main page is supposed to change to the one specified, then the pop-up appear and start the download, then the pop-up close by himself right after the download box appears.

    Can you give me a code for this one? Because I think that it's the easiest way...

    Thanks in advance.
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  8. #8
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to close the pop-up after a certain amount of time, we can use this: setTimeout('window.close()',200);

    Anyone got an idea for another code?
    Last edited by HeadSpin; Jun 9, 2003 at 09:41.
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  9. #9
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need help, please...
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  10. #10
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright man...you need to learn JavaScript for yourself...but here's the solution for your problem...

    <Script language="JavaScript">
    function newWin()
    {
    var child_window = window.open("file.exe","childWindow","width=200 height=200");
    }
    function goTo(pageName)
    {
    window.location.href = "http://www.yoursite.com/"+pageName+".html";
    }
    </script>

    <a href="javascript:newWin(),goTo('nextpage');">Download the file.</a>

  11. #11
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the code, but if I want the pop-up that will start the download to be minimized all the time, how can I introduce the function focusWin() in the code?

    And sorry if I can't write javascript, but I really need answer for my questions, because I don't have much time to study how to write them for the moment.

    Thanks in advance!
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  12. #12
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, try this then:
    Code:
    <Script language="JavaScript">
    function newWin()
    {
    var child_window = window.open("page1.html","childWindow","width=200 height=200");
    }
    function goTo(pageName)
    {
    window.location.href = "http://www.yoursite.com/"+pageName+".html";
    }
    function focusWin()
    {
    this.window.focus();
    }
    </script>
    <a href="javascript:newWin(),focusWin(),goTo('nextpage');">Download the file.</a>

  13. #13
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot, it's working now

    Your help was truly appreciated!
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  14. #14
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ohh, the pop-up is like a pop-under, but I need a pop-up that is totally minimized, not behind the other windows... A pop-up that is minimized in the task bar.

    Thanks in advance.
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World

  15. #15
    SitePoint Addict
    Join Date
    Aug 2001
    Location
    Los Angeles, CA
    Posts
    346
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry man, I don't know how to do that...and I'm not sure if it can even be done with JS...why is minimizing it so important anyways?

  16. #16
    SitePoint Enthusiast HeadSpin's Avatar
    Join Date
    May 2003
    Location
    Canada/Quebec
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because I can't let the pop-up in front or behind my main window, well it the rules of the advertising company...
    World of Warcraft Nation --> The next greatest MMORPG title

    Warcraft 3 World


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
  •