Solved

Displaying a new url onclick

Posted on 2003-11-17
7
3,850 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
RSS Feeds--IE 13 166
Disabling automatic web page translations 9 40
Tech Writing Terminology - Pane or Panel? 8 77
jQuery or Javascript animation question 6 66
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now