www.webdeveloper.com
Results 1 to 8 of 8

Thread: window.open.self - using a HTML button

  1. #1
    Join Date
    Feb 2007
    Posts
    10

    Wink window.open.self - using a HTML button

    Hi Everybody

    i have a html button that when clicked i want it to open the page within the same window. I have set the following code in the on-click event and it has the odd bit of PHP in too.

    the window.open.self just doesnt work, can any of you chaps offer a solution ??

    heres my code...

    HTML Code:
    <input type="button" onClick="javascript:window.open.self('?section=booking_edit_request&id=<?=$_GET['id']?>&action=go&makeBooking=yes');" value="Make Booking" />
    any help is most appriciated

    many thanks

    Truegilly

  2. #2
    Join Date
    Sep 2005
    Posts
    21
    Code:
    <input type="button" onClick="window.location='?section=booking_edit_request&id=<?=$_GET['id']?>&action=go&makeBooking=yes');" value="Make Booking" />
    something like this

  3. #3
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    um, you do not use window.open to change the location of the current page, instead you use the window.location object

    window.location.href = "mypage.html";

    Eric

  4. #4
    Join Date
    Feb 2007
    Posts
    10
    thanks for both your input

    ive been experimenting with the location method and carnt seem to get it working, i have tried a few different combinations of the location.href, losing the () round the expression and losing the javascript: thats at the begining of the onclick event.

    here is the code in its current state...

    HTML Code:
    <input type="button" onClick="window.location.href('?section=booking_edit_request&id=<?=$_GET['id']?>&action=go&makeBooking=yes');" value="Make Booking" />
    can you offer any suggestions ??

    many thanks

    truegilly

  5. #5
    Join Date
    Feb 2007
    Posts
    10

    Red face

    thanks for both your input

    ive been experimenting with the location method and carnt seem to get it working, i have tried a few different combinations of the location.href, losing the () round the expression and losing the javascript: thats at the begining of the onclick event.

    here is the code in its current state...

    HTML Code:
    <input type="button" onClick="window.location.href('?section=booking_edit_request&id=<?=$_GET['id']?>&action=go&makeBooking=yes');" value="Make Booking" />
    can you offer any suggestions ??

    many thanks

    truegilly

  6. #6
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    look at my example, there are no parenthesis. () is for executing a method, href os a property.

    Eric

  7. #7
    Join Date
    Nov 2009
    Posts
    3

    Getting HTML Select Values to Open in Same Browser Window

    Hi,

    I'm trying to couple the "window.location.href" command with the values in a straightforward HTML Select statement, with the intent to get the links to open in the same browser page. It should be simple but I seem to be stuck.

    I followed the advice in the thread but I can't seem to get the "window.location.href" command to work. If I use the "window.open" command, instead, the links open in new browser tabs without any issues, but I really need to get them to open in the same browser window/tab. Could someone please take a look at my code and advise as to what I'm doing wrong?

    Thanks, in advance, for any help you can offer.

    Frank

    Code...

    <h1>Menu Test</h1>
    <form name="Form1">
    <select style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" name="Drop1">
    <option value="http://www.google.com/" selected="selected">Google</option>
    <option value="http://www.if4it.com/">IF4IT</option>
    <option value="http://www.msn.com/">MSN</option>
    <option value="http://www.yahoo.com/">Yahoo</option>
    </select>
    <input
    onclick="window.location.href(document.Form1.Drop1.options [document.Form1.Drop1.selectedIndex].value); this.selectedIndex = 0; " value="Go" type="button">
    </form>

  8. #8
    Join Date
    Nov 2009
    Posts
    3

    How to Make HTML Selects Open in the Same Browser Window or Tab

    Hi,

    I received a message telling me that "J. H. Rasmussen" responded to my question. However, after logging back on, I don't see it online. I don't know if there's a delay between the mail notification system and the posting but I decided to include the post so that J. H. Rasmussen's solution could be shared with others...

    Thanks J. H. for your response. It worked, first try!

    If there are any other options that others are aware of, please feel free to share. All solutions are welcomed and appreciated.

    My Best,

    Frank

    -------------------------------------------------------------------

    FROM "J. H. Rasmussen"...


    This should do it:

    Code:
    ---------
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
    <head profile="http://www.w3.org/2005/10/profile">
    <title>HTML Select Menu Test Page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="-l" />
    <!--[if gt IE 7]> <style>body { overflow-y:scroll; } </style> <![endif]-->
    </head>
    <body>
    <h1>Menu Test</h1>
    <form name="Form1">
    <select style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" name="Drop1">
    <option value="http://www.google.com/" selected="selected">Google</option>
    <option value="http://www.if4it.com/">IF4IT</option>
    <option value="http://www.msn.com/">MSN</option>
    <option value="http://www.yahoo.com/">Yahoo</option>
    </select>
    <input onclick="top.location.href=document.Form1.Drop1.options[document.Form1.Drop1.selectedIndex].value; this.selectedIndex = 0; " value="Go" type="button">
    </form>
    </body>
    </html>
    ---------
    I removed window.open and added top.location.href. If the code is in a iframe, and you want the website to open in that iframe, then you can use location.href.

    top.location.href will make sure that the entire window is taken over by the new url.
    ***************

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles