A button on my site won't left-click (Javascript)
Asked by
Haroot (
2123)
February 2nd, 2011
So we have a school website for the arc. department of my school. The site was made with dreamweaver and contains a 4×4 grid. A navigation bar on the left with buttons will take you the different squares on the grid. Now we also have a number 17 button. This button is meant to open a new window to pdf (right now we just have it going to google.)
Now the problem is when I left-click this button, nothing happens. On the other hand if I right-click than open, ctrl-left click or right-click to open in a new tab.
Now if I make any changes to the buttons code (like add a height and width to the new window that is suppose to open,) it will work, but the rest of the navigation bar that moves you from button to button stops working.
Here’s what the piece of code looks like for the the #16 and #17:
});
$(’#re2li-16’).click(function() {
$paneTarget.stop().scrollTo( ‘li:eq(15)’, 1000);
});
$(’#re2li-17’).click(function() {
onclick=“window.open (‘http://www.google.com’)”;
});
Any ideas?
Observing members:
0
Composing members:
0
7 Answers
First off, you shouldn’t be using buttons for navigation at all. Buttons should only be used to submit forms. In order to link to a new page, you should use the standard <a href=“url”>Link Text</a>
tag. A url beginning with a #hash will lead you to the element with a matching id
.
No good website launches pop-up windows, but if you absolutely must open a new window, do so by adding a target=“_blank”
attribute to the a
tag.
Do you mean submit buttons that are only to be used with a form? then, no!!!!!!!!!!!!
If you are referring to a image button, then why use javascript?
You can use css on a link to show a nice button that will change when you hover on it or click on it.
try reading this: http://kyleschaeffer.com/best-practices/pure-css-image-hover/
I’m not at the computer right now so I can’t test any of this out. I think the word button may have been wrong to use. It’s just text. So technically a link that opens a new window. The other 16 text links push around the screen.
And for the record I haven’t done any of this stuff for years. I work at my University’s printing lab/computer room. I just fix computer problems and plot (print) posters. My boss just came to me today with this since I’ve done it over four years ago…
Ah, yes. Trash the Javascript associated with the link, and simple add a target=“_blank”
attribute. Then make sure the href of the a
link shows the correct URL.
Did it to no avail.
So the index has currently:
<li><a id“2li-17” href=“http://www.google.com” target=“_blank”>Text Goes Here<a/><li>
And the init.js file has what was posted above.
$(’#re2li-17’).click(function() {
onclick=“window.open (‘http://www.google.com’)”;
also has the absolute
$(’absolute-17’).click(function() {
onclick=“window.open (‘http://www.google.com’)”;
You forgot an equal sign after the id
attribute in the a
tag. Also, the Javascript is not needed. You may safely remove the function with no problems.
Okay problem solved.
Actually Vortico that was a typo here. But the problem was it was suppose to be re2li-17.
Thank you for your help! I wouldn’t have noticed it if you didn’t say anything.
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.