/    Sign up×
Community /Pin to ProfileBookmark

How do I make the button _blank new window?

<input type=”button” value=”Download” onClick=”location.href=’www.msn.com”>

I’m drawing a blank here, how do I make my form button default to _blank (new window) for the link?

DB

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Apr 29.2004 — <i>
</i>&lt;form method="get" action="http://www.msn.com" target=_blank"&gt;
&lt;input type="submit" value="Download"&gt;
&lt;/form&gt;
Copy linkTweet thisAlerts:
@d_brandusaauthorApr 29.2004 — <form method="get" action="http://www.msn.com" target=_blank">

<input type="submit" value="Download">

</form>

Won't work for me, I need the blank in the button itself, I am using a call to javascript for special "accept terms" before the button is active. That all works great, I just need the onclick link to go to _blank window.

<form name="agreeform" onSubmit="return defaultagree(this)">

<input type="button" value="Download" onClick="location.href='www.msn.com'">

</form>
Copy linkTweet thisAlerts:
@crh3675Apr 29.2004 — Then you need to create a popup window:

<i>
</i>&lt;input type="button" value="Download" onClick="window.open('http://www.msn.com','pwin')"&gt;
Copy linkTweet thisAlerts:
@d_brandusaauthorApr 29.2004 — That works great, how I do add no address bar menu and scroll bar to hide the addy information?
Copy linkTweet thisAlerts:
@crh3675Apr 29.2004 — <i>
</i>onClick="window.open('http://www.msn.com','pwin','location=no,status=no,scrollbars=no,resizeable=yes,toolbar=no')"
Copy linkTweet thisAlerts:
@d_brandusaauthorApr 29.2004 — Thanks so much craig, you've been alot of help. One last question, is it possible for the button to be a thumbnail img for example a 100x50 pixels and reference back to /button/img1.jpg kinda thing, is that possible?

DB
Copy linkTweet thisAlerts:
@crh3675Apr 29.2004 — Just change the input type to "image"

and specify a "src" attribute
Copy linkTweet thisAlerts:
@d_brandusaauthorApr 29.2004 — Okay, everything works fine, I have this javascript where if they click on the accept terms the buttons become active so the links inside them will work. This works perfect now thanks to craigs help with the code within the button. I asked if this can now be an image if I wanted to. It doesn't work, can you tell me if it is possible to do so?

Here is my javascript, its included in the page javascript.js

<!-- Accept Terms / Logos & Guidelines -->

var checkobj

function agreesubmit(el){

checkobj=el

if (document.all||document.getElementById){

for (i=0;i<checkobj.form.length;i++){

var tempobj=checkobj.form.elements[i]

if(tempobj.type.toLowerCase()=="button")

tempobj.disabled=!checkobj.checked

}

}

}



function defaultagree(el){

if (!document.all&&!document.getElementById){

if (window.checkobj&&checkobj.checked)

return true

else{

alert("Please read/accept terms to submit form")

return false

}

}

}



<!-- End -->



This works fine with this form:



<form name="agreeform" onSubmit="return defaultagree(this)"><b>TERMS GO HERE.</b><textarea rows="5" name="Disclaimer" cols="61" style="color: #000080; border: 1px solid #000080; background-color: #FFFFFF">TERM IN BOX</textarea>I agree to the above terms</b><input name="agreecheck" type="checkbox" onClick="agreesubmit(this)">



<input type="button" value="Download" onClick="window.open('http://www.msn.com','website','location=no,status=no,scrollbars=no,resizeable=yes,toolbar=no')" disabled">



</form>



The button becomes active when they hit the check box to agree. Now can this script be modified so it works with an "image button" to do the same, stay inactive until they click then the image button will work. Will it be shaded out like the button, this is another question.



Can it work with this instead of the form button, but image button.



<input type="image" border="0" name="Download" src="button_img.jpg" width="125" height="75" onClick="window.open('large.jpg','jpg','location=no,status=no,scrollbars=no,resizeable=yes,toolbar=no')">
Copy linkTweet thisAlerts:
@crh3675Apr 29.2004 — I think we need to add a return false after our window call since an INPUT type of IMAGE acts as a submit button so:

<i>
</i>&lt;input type="image" border="0" name="Download" src="button_img.jpg" width="125" height="75" onClick="window.open('large. jpg','jpg','location=no,status=no,scrollbars=no,re
sizeable=yes,toolbar=no');return false"&gt;
×

Success!

Help @d_brandusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...