I want to author an anchor tag that executes some JavaScript and then proceeds to go wherever the href
was taking it.(我想创建一个执行一些JavaScript的锚标签,然后继续前进到href
所在的任何地方。)
Invoking a function that executes my JavaScript and then sets window.location
or top.location
to the href
location doesn't work for me.(调用执行我的JavaScript然后将window.location
或top.location
设置为href
位置的函数对我来说不起作用。)
So, imagine I have an element with id "Foo" on the page.(所以,想象一下我在页面上有一个id为“Foo”的元素。)
I want to author an anchor similar to:(我想创作一个类似于的锚:)
<a href="#Foo" onclick="runMyFunction(); return false;">Do it!</a>
When this is clicked, I want to execute runMyFunction and then jump the page to #Foo
(not cause a reload - using top.location
would cause it to reload the page).(单击此按钮时,我想执行runMyFunction,然后将页面跳转到#Foo
(不会导致重新加载 - 使用top.location
会导致重新加载页面)。)
Suggestions?(建议?)
I am happy to use jQuery if it can help here...(我很高兴使用jQuery,如果它可以在这里帮助...)
ask by psychotik translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…