修改 JavaScript 翻转脚本

发布于 2024-07-10 12:00:50 字数 791 浏览 13 评论 0原文

我正在尝试在 blogspot 上实现此 JavaScript 代码(它解析 XML 代码,有些代码比其他代码工作得更好)

 </head><body>
<div class="navbar section" id="navbar"><div class="widget Navbar" id="Navbar1"><script type="text/javascript">
    function setAttributeOnload(object, attribute, val) {
      if(window.addEventListener) {
        window.addEventListener("load",
          function(){ object[attribute] = val; }, false);
      } else {
        window.attachEvent('onload', function(){ object[attribute] = val; });
      }
    }
  </script>

该代码可以通过以下片段实现翻转:

<img xsrc="/1.jpg" class="domroll /1flip.jpg" src="/1.jpg">

我想修改代码,以便它将替换与当前鼠标悬停时的图像不同的图像,但到目前为止还没有运气。 (也许通过命名它们并将名称作为变量传递)

任何人都可以帮忙吗?

谢谢

I'm trying to implement this JavaScript code on blogspot (which parses XML code, some code works better than others)

 </head><body>
<div class="navbar section" id="navbar"><div class="widget Navbar" id="Navbar1"><script type="text/javascript">
    function setAttributeOnload(object, attribute, val) {
      if(window.addEventListener) {
        window.addEventListener("load",
          function(){ object[attribute] = val; }, false);
      } else {
        window.attachEvent('onload', function(){ object[attribute] = val; });
      }
    }
  </script>

That code results in rollover just fine with the following snip:

<img xsrc="/1.jpg" class="domroll /1flip.jpg" src="/1.jpg">

I'd like to modify the code so that it would replace a different image rather than the one it's currently under mouseover, but so far without luck. (perhaps by naming them and passing the names as variables)

Can anyone help?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

于我来说 2024-07-17 12:00:50

您发布的 JavaScript 片段与图像翻转没有任何关系,并且不会生成第二个片段。

第一个片段允许您以跨浏览器的方式更改 DOM 节点 onLoad 的属性。 您可能需要编辑您的问题以添加适当的代码片段。

The snippet of JavaScript you have posted doesn't have anything to do with image rollovers, and doesn't produce the second snippet.

The first snippet allows you to change the attribute of an DOM node onLoad in a cross browser fashion. You might want to edit your question to put up the appropriate snippet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文