Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts

    target=_blank type function on a submit button

    I need to find a way to open a new _blank type window when a user submits. I have found a few answers but none that fit what i need. alot tell you to use target blank on submit, but i have two buttons that do 2 completely different things.


    Is there a way to achieve that? here is the code i use!

    Code:
    <form name="done">
    <div class="photoContainer">
    
    <p class="process">Photos Successfully Uploaded</p>
    
    <div class="processbtns">
    
    <input class="button space" type="button" target="_blank"  value="View Photos on ebby.com" 
    	onclick="window.location.href = 'http://www.ebby.com/details/<?=$propid?>.html';"/>
    <input class="space" type="button" value="Manage Photos" onclick="window.location.href = '/photomanager/manage/<?=$propid?>';"/>
    
    </div>
    
    
    </div>
    </form>
    Thanks!

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,561
    Thanks
    80
    Thanked 4,494 Times in 4,458 Posts
    You can't use target= as an attribute of a *BUTTON*.

    target is only valid in A, AREA, BASE, FORM, and LINK elements.

    With a button, you will need to use JavaScript to do a window.open( ) call in order to specify a target window.

    That is, something like:
    Code:
    <input class="button space" type="button" value="View Photos on ebby.com"
        onclick="window.open('http://www.ebby.com/details/<?=$propid?>.html','_blank');" />
    And you don't *HAVE* to use _blank. In fact, if you want to purposely reuse an existing window, just use a specific name. If no window of that name exists, then a new one is created. But if such a window already exists, then the give url will populate it.

    I do that all the time with image popups on my own site, for example:
    Code:
    <input type=button value="show me"
        onclick="window.open('/images/foo.jpg', 'PICTURE', 'width=500,height=300');">

  • Users who have thanked Old Pedant for this post:

    jcdevelopment (03-03-2009)

  • #3
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    Well, i would use a new window which wouldn't be a problem. Its just i was trying to be, less annoying i guess and just have a new tab show up on newer browsers. I can't tell if that is less annoying though.

    Thank you though!

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    I guess the real question here is why are you using buttons to begin with? They aren't submitting the form they are in. They are just links to other pages. Why not style the links to look like buttons? Its a more elegant solution as it will fit in with your design as well.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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