/    Sign up×
Community /Pin to ProfileBookmark

OnClick to Web Address Error

I have the following code on a button:

[code]
<input type=”button” value=”Add Project” style=”font-family: Verdana; font-size: 8pt” onclick=”go(‘ProjectList-add.asp’)”>
[/code]

All I want it to do is work as a hyperlink and go to that web page; however, nothing happens and I get a javascript error Object Expected. Any ideas?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@balloonbuffoonApr 13.2006 — Do you have a function named "go"?

Try this:
[CODE]<input type="button" value="Add Project" style="font-family: Verdana; font-size: 8pt" onclick="top.location='ProjectList-add.asp'">[/CODE]

--Steve
Copy linkTweet thisAlerts:
@dzirkelbauthorApr 13.2006 — That worked, thanks!
Copy linkTweet thisAlerts:
@balloonbuffoonApr 13.2006 — No problem!

--Steve
Copy linkTweet thisAlerts:
@stephen1davisApr 13.2006 — Hey Steve

what's the difference between saying "top.location=" and "location.href="?
Copy linkTweet thisAlerts:
@balloonbuffoonApr 13.2006 — Actually, I don't know. I have found that any of the following will work:

top.location

window.location

location.href

location

...others, I guess.

I [I]think[/I] top.location will make sure to break out of a frame, if its in one, but I'm not sure. Does anyone else know?

--Steve
Copy linkTweet thisAlerts:
@hyperliskApr 14.2006 — 
I [I]think[/I] top.location will make sure to break out of a frame, if its in one, but I'm not sure. Does anyone else know?
[/QUOTE]

Yes you are correct. top.location takes the top-most document in the window. So say a document has frames, and those frames have frames also. top.location will change the whole pages location instead of just the frame that calls it.
×

Success!

Help @dzirkelb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...