Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: window.location.href

  1. #1
    Join Date
    Nov 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default window.location.href

    Right, this is such a pain, I can't believe its not possible!

    I am using window.location.href but can't appy a target blank to it! Just self or top...why is that?

    Any other options?

    window.open ?

    Cheers
    SBM

  2. #2
    Join Date
    Aug 2004
    Posts
    9,893
    Thanks
    3
    Thanked 966 Times in 954 Posts
    Blog Entries
    15

    Default

    Try:

    Code:
    window.parent.location="http://www.google.com"
    This will cause Google.com to be loaded in the browser window, clearing any frames if it's inside one.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,994
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    Just in case ddadmin has missed what I think the question is here, I think what you are looking for is the window.open() method. It is the javascript equivalent to the html anchor tag with the target attribute set to _blank. Here is how it is used to open a basic new window:

    window.open('some.htm')

    If you can follow this logic, the window.open() part replaces:

    target="_blank"

    and the 'some.htm' part replaces:

    href="some.htm"

    If ddadmin got it right, this post will self destruct in 10 seconds.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Nov 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you both, and thank you mad professor for answering correctly!

  5. #5
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default window.open() method

    Hi
    I have an add on to this post.

    I am a newbie at JavaScript.
    Can the window.open() method be added to the following line of code so it redirects on the click to a new browser ?
    onClick="window.location.href = 'some.htm'"

    Thanks

    Mark

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,994
    Thanks
    43
    Thanked 3,198 Times in 3,160 Posts
    Blog Entries
    12

    Default

    Code:
    <span onclick="var bob=window.open('','_blank');bob.location='some.htm';">Whatever</span>
    But one can just as easily:

    Code:
    <span onclick="window.open('some.htm','_blank');">Whatever</span>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Nov 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thats perfect !

    Thankyou very much.

    Mark

  8. #8
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    Hi i have a question a bit different that probably touch everything you wrote in this tread.

    I need to open a pop up window from a list i generated from a database.

    Up to now this is what i was using to see my results from my list.
    Code:
    <?php
    [...]
    echo '  <tr class="content" onmouseout="this.className=\'content\'" onmouseover="this.className=\'mouseover\'"
        onclick="location.href=\'add.php?id='.$line['id'].'\'">';
    [...]
    ?>
    The problem is i need to make the page appear in a pop-up window.
    I need to be able to set the width and height of that window also.
    I tried several things but i still didn't found anything that worked since its in a <TR>.

    Any tips or help would be greatly appreciated.
    Thanks

    G78.
    Last edited by g78; 04-20-2008 at 03:08 PM.

  9. #9
    Join Date
    Jan 2008
    Posts
    4,167
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try this:
    Code:
    <?php
    [...]
    echo '  <tr class="content" onmouseout="this.className=\'contenu\'" onmouseover="this.className=\'mouseover\'"
        onclick="location.href=\'add.php?id='.$ligne[id].'\'">';
    [...]
    ?>
    Jeremy | jfein.net

  10. #10
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Erm, are you saying it can't be done?

    Its the exact same code.

    Heres the full function.
    Code:
    <?php
    
      function ShowContent($line) {
    
        global $Columns;
    
        echo '  <tr class="content" onmouseout="this.className=\'content\'" onmouseover="this.className=\'mouseover\'"
        onclick="location.href=\'add.php?id='.$line['id'].'\'">';
        foreach ($Columns as $col => $title) {
          if ($line[$col]) {
            echo '<td>';
            echo htmlentities($line[$col]);
            echo '</td>';
          }
        }
        echo "</tr>\n";
    
      }
    ?>
    Last edited by g78; 04-20-2008 at 03:09 PM.

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
  •