需要有关图像按钮的帮助
<a href="#"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('Home','','Images/menuButtons/home_out.png',1)"
onclick="alert("Hello")" ><img onclick="alert("Hello")"
src="Images/menuButtons/home_on.png"
alt="Home" name="Home" width="164" height="64" border="0" id="Home" />
</a><br/>
我正在尝试创建一个带有翻转图像的导航菜单栏。翻转图像部分是由 Dreamweaver 创建的,因此所有这些 MM_functions
。但是onclick
,我想更改主框架的内容,而不仅仅是打开一个超链接。
所以我尝试了 onclick="JS_funtion()"
以及 onMouseDown
和 onMouseUP
。似乎什么都不起作用。它甚至没有调用示例所示的函数,我尝试调用 alert()
但仍然无法正常工作。我是 HTML/Javascript 新手。
我做错了什么?
我的网站是 www.sitebloviate.com
<a href="#"
onmouseout="MM_swapImgRestore()"
onmouseover="MM_swapImage('Home','','Images/menuButtons/home_out.png',1)"
onclick="alert("Hello")" ><img onclick="alert("Hello")"
src="Images/menuButtons/home_on.png"
alt="Home" name="Home" width="164" height="64" border="0" id="Home" />
</a><br/>
I'm trying to create a navigation menubar with rollover images. Rollover Image part was created by Dreamweaver hence all those MM_functions
. But onclick
, I want to change the content of main frame, not just open a hyperlink.
So I tried onclick="JS_funtion()"
aswell as onMouseDown
and onMouseUP
. Nothing seemed to work. It's not even calling the functions as the example shows, I tried to call alert()
and still not working. I'm new to HTML/Javascript.
What am I doing wrong?
My site is www.sitebloviate.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Arjan 是对的,你不能在双引号属性中使用双引号。
其他事项:
onclick
,锚标记即可,href="#"
通常是不好的做法。最好将其设为真正的链接,这样如果用户右键单击并选择“在新选项卡中打开”,就会将他们带到有意义的地方。但要执行后者,您需要通过返回 false 来取消事件。
例子:
Arjan is right, you can't use double quotes inside a double-quoted attribute.
Other things:
onclick
in your image, the anchor tag will do,href="#"
is generally bad practice. It's better to make it a real link so that if the user right-clicks and chooses "open in new tab" it takes them somewhere meaningful.To do the latter though, you'll need to cancel the event by returning false.
Example:
如果将
onclick="alert("Hello")"
替换为onclick="alert('Hello')"
(请注意 ( 和 ) 之间的不同引号),它将工作。If you replace
onclick="alert("Hello")"
withonclick="alert('Hello')"
(note the different quotes between ( and ) ) it will work.我认为你的问题是你的
onclick="alert("Hello")"
应该是onclick="alert('Hello')"
用单引号来指示文字字符串。那里大概是窒息了。I think your problem is your
onclick="alert("Hello")"
should beonclick="alert('Hello')"
with single quotes to indicate a literal string. It's probably choking there.