Solved

Displaying a new url onclick

Posted on 2003-11-17
7
3,856 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 50 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 50 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 
LVL 17

Expert Comment

by:dorward
ID: 9767663
0
 
LVL 2

Accepted Solution

by:
incongruent earned 150 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

724 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