By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

how to open a page(in the same browser window) when clicking

P: n/a
how do I open a page in the same browser window using onclick?

Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Try to use
onclick="<script>window.location='page.html'</script>";

http://www.DevPlug.com --Connecting Developers
Posted from: http://www.devplug.com/ftopic32129.htm
Jul 17 '05 #2

P: n/a
ad***@devplug-dot-com.no-spam.invalid (rovisoft) wrote:

Try to use
onclick="<script>window.location='page.html'</script>";


The contents of an event handler are always Javascript, and the string
"<script>" is a syntax error in Javascript. Do this instead:

onClick="window.location='page.html'"
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 17 '05 #3

P: n/a
i get the answer object does not support this action

Jul 17 '05 #4

P: n/a
> Tim Robertswrote:
ad***@devplug-dot-com.no-spam.invalid (rovisoft) wrote:

Try to use
onclick="<script>window.location='page.html'</script>";

The contents of an event handler are always Javascript, and the
string
"<script>" is a syntax error in Javascript. Do this instead:

onClick="window.location='page.html'"
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.[/quote:f07927e48d]
by doing that it will still open a new browser window, isn't there a
way to keep it in the same window?

Jul 17 '05 #5

P: n/a
window.location=url shouldn't open a new window. It should change the
current window's location.

window.open() is used for opening new windows.

Browsers can override these settings, however. Maybe an option is set
to open all links in separate windows/tabs.

-aaron

Jul 17 '05 #6

P: n/a
LOL. Think before you post, people.

It should be onclick="location.href = 'page.html'". Window.location is
an object.

If you want the new page to replace the current page in the history,
use location.replace(url).

Jul 17 '05 #7

P: n/a
ra************@yahoo-dot-com.no-spam.invalid (clod) wrote:
Tim Robertswrote:

The contents of an event handler are always Javascript, and the
string "<script>" is a syntax error in Javascript. Do this instead:

onClick="window.location='page.html'"


by doing that it will still open a new browser window, isn't there a
way to keep it in the same window?


In saying that, you are simply confirming that you didn't even try it.

Assigning to window.location replaces the contents of the current browser
window. It does not open a new one.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.