[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Displaying a new url onclick

Posted on 2003-11-17
7
Medium Priority
?
3,860 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

656 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