Open new page in the same browser window?

B

Benton

Hi there,

Newbie here. I want to click a HTML button and cause a new web page to load
in the current browser window. What "onclick" attribute should I add to this
button?


Thanks a lot,

-Benton
 
V

VK

Benton said:
Hi there,

Newbie here. I want to click a HTML button and cause a new web page to load
in the current browser window. What "onclick" attribute should I add to this
button?

....
<button type="button"
onclick="window.location.href='http://www.google.com';">Click
me</button>
....
 
T

Thomas 'PointedEars' Lahn

None at all. It is better to ignore VK.
...
<button type="button"
onclick="window.location.href='http://www.google.com';">Click
me</button>
...

<script type="text/javascript">
document.write('<input type="button"'
+ ' value="Go to Google"'
+ ' onclick="window.location = 'http://www.google.com/';">');
</script>

is far better than the above.

<a href="http://www.google.com/"
style="border:2px outset; padding:3px; text-decoration:none"
Go to Google</a>

and the like (preferably using the `style' _element_ instead) is
even better than that. No script is needed here at all.


PointedEars
 
T

Thomas 'PointedEars' Lahn

None at all. It is better to ignore VK.
...
<button type="button"
onclick="window.location.href='http://www.google.com';">Click
me</button>
...

<script type="text/javascript">
document.write('<input type="button"'
+ ' value="Go to Google"'
+ ' onclick="window.location = \'http://www.google.com/\';">');
</script>

is far better than the above.

<a href="http://www.google.com/"
style="border:2px outset; padding:3px; text-decoration:none"
Go to Google</a>

and the like (preferably using the `style' _element_ instead) is
even better than that. No script is needed here at all.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top