?
Solved

Displaying a new url onclick

Posted on 2003-11-17
7
Medium Priority
?
3,859 Views
Last Modified: 2008-02-01
Sorry, I forgot this one.

I want to display a new web page when I click on a button.

Something like:

onClick='javascript:url( "theWebPageIWant")'

0
Comment
Question by:rfr1tz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 19

Assisted Solution

by:Dexstar
Dexstar earned 200 total points
ID: 9766198
rfr1tz:

> onClick='javascript:url( "theWebPageIWant")'

Try this:
     onclick='javascript:document.location.href="theWebPageIWant"';

Hope That Helps,
Dex*
0
 
LVL 16

Assisted Solution

by:jaysolomon
jaysolomon earned 200 total points
ID: 9766415
<a href="theWebPageIWant" onclick="location.href = this.href;return false">Go</a>

1 you do not need the javascript: protocol since onclick is part of JS.

2 if you do it this away, even javascript disabled browsers will be able to go to that page also.
0
 
LVL 7

Expert Comment

by:wsteegmans
ID: 9766454
You could also create an new JavaScript Function, like this one ..

function OpenNewWindow(url, wWidth, wHeight)
{      var wTop      = 0
      var wLeft      = 0
      var openProps
      
      if (screen)
      {            
                  wLeft      = (screen.width  / 2) - (wWidth / 2)
                  wTop      = (screen.height / 2) - (wHeight / 2)
      }
      openProps = "width="+wWidth+",height="+wHeight+",left="+wLeft+",top="+wTop;
      return window.open(url,"win",openProps,'location=no, menubar=no, toolbar=no')

}

This function has three parameters, the url, the width and the heigth. An example of calling this function is (in your case):
  onclick="javascript:OpenNewWindow('http://www.experts-exchange.com', 800,600);"
This function opens a new window (nice centered on the screen) without addressbar, buttons, ... So, try it out ...

For more info about the window.open statement:
http://www.devguru.com/technologies/ecmascript/quickref/win_open.html
0
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

 
LVL 17

Expert Comment

by:dorward
ID: 9767663
0
 
LVL 2

Accepted Solution

by:
incongruent earned 600 total points
ID: 9769420
to give you exactly what you asked for:

<input type=button name=cmdButton value="Click Me" onClick="document.location.href='theWebPageIWant.html';">


or if you want it to open in a popup window:

<input type=button name=cmdButton value="Click Me"
onClick="window.open('theWebPageIWant.html','','width=500,toolbar=yes,height=500,status=yes');">

-Cheers,

Allan
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9769969
document.locaiton is supposed to be read-only and won't work being set in some browsers. Use window.locaiton.
0
 
LVL 1

Expert Comment

by:umangjoshi
ID: 9770808
just try this

<input type="button" name="btn1" value="Click Here" onClick="location.href = 'xyz.html'; ">
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question