复合MouseOver [英] Compounding MouseOver

查看:50
本文介绍了复合MouseOver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个模仿Radiohead网站的动作这个页面,但问题是他们使用PHP来实现效果,我不知道PHP。我非常业余:对HTML非常自信,可以通过大量研究和诅咒将代码与JavaScript拼凑在一起,但对于我的生活,我看不到如何鼠标悬停图像或文本A,获取图像或文本B,鼠标悬停B,获取图像或文本C,依此类推。我确信它可以在不需要学习PHP的情况下完成,但到目前为止我使用的文本并不能识别第二次鼠标悬停。当然,它会识别第二个标签,因为文本会显示为链接,但当我将鼠标悬停在第二个短语上时,它什么都不做。


[HTML]< html>

< head>

< script language = javascript>


var first_text =''< a href =#onMouseOver =文件撰写(second_text);大于1< / A> '';

var second_text = first_text +''< a href =#onMouseOver = document.write(third_text);> 2< / a> '';

var third_text = first_text + second_text +''3'';


< / script>

< ; / head>

< body>

< script>


document.write(first_text);


< / script>


< / body>

< / html> [/ HTML]


有人可以帮忙吗?我有一种感觉,我已经解释得很糟糕了......

I''m trying to create a design which mimics the Radiohead website in the action on this page, but the problem is that they use PHP for the effect and I have no idea about PHP. I''m very amateur: fairly confident with HTML and can scrape together codes with JavaScript with a lot of research and cursing, but for the life of me I can''t see how to mouseover image or text A, get image or text B, mouseover B, get image or text C, and so on. I''m sure it can be done without needing to learn PHP but the text I am using so far doesn''t recognise the second mouseover. It recognises the second a tag, certainly, as the text comes up as a link, but when I mouseover the second phrase it does nothing.

[HTML]<html>
<head>
<script language=javascript>

var first_text = ''<a href=# onMouseOver=document.write(second_text);>1</a> '';
var second_text = first_text + ''<a href=# onMouseOver=document.write(third_text);>2</a> '';
var third_text = first_text + second_text + ''3'';

</script>
</head>
<body>
<script>

document.write(first_text);

</script>

</body>
</html>[/HTML]

Can anybody help? I have a feeling that I''ve explained this badly...

推荐答案

欢迎来到剧本。


那个无法工作。你正在使用循环引用,其中second_text尚未定义,你在first_text中使用它,second_text包含first_text,而first_text又包含second_text(你最终会旋转!)


而是定义一个包含所有链接/文本的数组,并在每个鼠标悬停时循环更改鼠标悬停或使用div / span并更改innerhtml。
Welcome to The Scripts.

That cannot work. You are using a circular reference where second_text has not been defined and you are using it in first_text and second_text contains first_text which in turn contains second_text (and you end up in a spin!)

Instead define an array which contains all links/text and loop through them changing the mouseover on each mouseover or use a div/span and change the innerhtml.


好的。请记住,我对此知之甚少。几乎所有的JavaScript都被剪切并粘贴在一起,直到它工作,所以从头开始几乎注定要失败。有鉴于此,我没有机会成功地使用它,如果没有一个万无一失的指导,说明这些事情的意义。我真正需要为我平板包装的方法是如何创建一个链接,在鼠标悬停上创建另一个链接,在无限小鼠广告上创建另一个链接。像鼠标悬停菜单一样,但每个级别只有一个选项。我一直在寻找这些,但他们似乎都要求首先上传实用工具,而且我没有选择使用外部文件。我在< a href>中处理我的鼠标悬停事件标签,显然你不能放在一起,所以我总是不知道如何提取这个并把它放到一个JS脚本中,对此事的无休止的研究只会让我更加困惑。 br />

如果有人有时间整理白痴指南等几个步骤,我将永远感激不尽。我可能会嫁给你。
Alright. Remember that I know very little about this. Pretty much all of my JavaScript is cut and pasted together until it works, so starting from scratch is pretty much doomed to failure. In view of this, I have all of no chance of being able to use that successfully without a foolproof guide of how such things are meant to go. What I really need flatpacked for me is how you create a link which creates another link on mouseover which creates another link on mouseover ad infinitum. Like a mouseover menu, but with only one option on each level. I''ve been looking these up but they all seem to require utilities to be uploaded first, and I don''t have the option of using external files. I handle my mouseover events in <a href> tags, which obviously you can''t place within one another, so I have a grand total of no idea of how to extract this and put it into a JS script, and endless research into the matter has only left me more confused.

If anybody has the time to put together a few steps of The Idiot''s Guide etc., I would be eternally grateful. I may marry you.


在IExplorer中尝试这个定向样本,如果有帮助请告诉我。

[HTML]< html>

< head>

< title> Untitled Document< / title>

< script language =" javascript">

window.onload = function(){

var c1 = document.getElementById(" c1");

c1.attachEvent(" onmouseover" ;,show);

}

函数show(){

var sender = window.event.srcElement;

var r = sender.parentElement;

if(r.cells.length> = 10)return;

var c = r.insertCell(-1);

c.id =" c" + r.cells.length;

c.innerHTML =" text" + r.cells.length;

c.attachEvent(" onmouseover",show);

c.attachEvent(" onmouseout",reset);

r.appendChild(c);

sender.detachEvent(" onmouseover",show);

sender.detachEvent(" onmouseout",reset );

}

函数reset(){

var c = window.event.srcElement

var r = c.parentElement;

var i = 0;

var len = r.cells.length;

for(i = len-1 ; i> = 1;我 - ){

r.removeChild(r.cells(i));

}

c =文件.getElementById(" c1");

c.attachEvent(" onmouseover",show);

}

< / script> ;

< / head>


< body>

< table id =" t1" border =" 1">

< tr id =" r1">

< td id =" c1"> text1< / td> ;

< / tr>


< / table>

< / body>

< / html> [/ HTML]
Try this orientative sample in IExplorer, and please let me know if it helps or not.
[HTML]<html>
<head>
<title>Untitled Document</title>
<script language="javascript">
window.onload = function (){
var c1 = document.getElementById("c1");
c1.attachEvent("onmouseover", show);
}
function show(){
var sender = window.event.srcElement;
var r = sender.parentElement;
if (r.cells.length >= 10) return;
var c = r.insertCell(-1);
c.id = "c" + r.cells.length;
c.innerHTML = "text" + r.cells.length;
c.attachEvent("onmouseover",show);
c.attachEvent("onmouseout",reset);
r.appendChild(c);
sender.detachEvent("onmouseover",show);
sender.detachEvent("onmouseout",reset);
}
function reset(){
var c = window.event.srcElement
var r = c.parentElement;
var i = 0;
var len = r.cells.length;
for (i=len-1;i>=1;i--){
r.removeChild(r.cells(i));
}
c = document.getElementById("c1");
c.attachEvent("onmouseover", show);
}
</script>
</head>

<body>
<table id="t1" border = "1">
<tr id="r1">
<td id="c1">text1</td>
</tr>

</table>
</body>
</html>[/HTML]


这篇关于复合MouseOver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆