473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing a URL as a parameter does not appear to work

Hi All

Very new to web page design here. Week 1 in fact.

I have a javascript function that is called in an OnClick event for a
button.
I am attempting to get the function to open a web page in a new window
in response to a button click.

I can get the page to open if I use the following syntax (hard code the
address)

var newwin =
indow.open("http://www.w3schools.com","","width=1200height=1000");

However, If I pass the url in as a parameter to the function (as below)
the value passed in is "Undefined" and obviously the page will not open

function openThePage(url)
{ url = "http://www." + url;
var newwin = window.open(url,"","width=1200height=1000");
}

<input
class="mybutton"
type="button"
name = "W3Schools"
value="w3schools.com"
onclick="openMyUrl(W3Schools.Value)">
&nbsp;&nbsp;

Anyone any idea how I can do what I want - what I am doing wrong. I am
grey enough as it is and I don't want to start pulling my hair out.

Thanks for help offered

Iain

Oct 9 '05 #1
1 2556
Em**************@gmail.com wrote:

Very new to web page design here. Week 1 in fact.
Week 1 and you're on JavaScript already?! I wouldn't advise touching it
until you had mastered HTML and become proficient with CSS.
I am attempting to get the function to open a web page in a new window
in response to a button click.
Oh dear. Foisting new windows on users is a very bad idea at least 99% of
the time.
I can get the page to open if I use the following syntax (hard code the
address) var newwin =
indow.open("http://www.w3schools.com","","width=1200height=1000");
I'm assuming you accidently dropped the "w" from the start and you actually
have a comma in that last bit. That's a huge window though, it won't fit on
most screens.
However, If I pass the url in as a parameter to the function (as below)
the value passed in is "Undefined" and obviously the page will not open <input
class="mybutton"
type="button"
name = "W3Schools"
value="w3schools.com"
onclick="openMyUrl(W3Schools.Value)">


What is "W3Schools"? Most browsers do not create global variables with a 1:1
correspondence to any element with a name, and I think that the "Value"
property is case-sensitive (and all lower-case) anyway.

onclick="openMyURL(this.value);"

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Oct 9 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: WGW | last post by:
Though I am a novice to MS SQL server (2000 I believe), I can do almost! everything I need. Maybe not efficiently, but usefully. However, I have a problem -- a complex query problem... I can...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
7
by: Robert Lario | last post by:
For examples sake I have made up a very simple example. I have an object called foo1 which is of type foo. I want to be able to call a funtion called myfunc as follows: myfunc(ref foo1) ...
4
by: Ron Rohrssen | last post by:
I want to show a dialog and when the form (dialog) is closed, return to the calling form. The calling form should then be able to pass the child form to another object with the form as a...
2
by: Mat Andrews | last post by:
Hi, I'm comfused with this peice of code which I'm looking at. I can't figure out how it works (and it does appear too); ApplicationData appData = new ApplicationData(); ...
0
by: stevag | last post by:
I have stored a variable ABC in a ASP.NET page and I use xsltArglist.AddParam in order to add this variable as a parameter to the binded XSLT transformation. In the associated .xslt file I use...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
10
by: Janus | last post by:
Hi, Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this: var...
4
by: Deckarep | last post by:
Hello fellow C# programmers, This question is more about general practice and convention so here goes: I got into a discussion with a co-worker who insisted that as a general practice all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.