![]() |
how to stop page jump, but still play sound?
Hi all
I'm trying to play a single short sound --- it works --- but the page jumps to bottom (i'm using chrome). How can I stop the page jump? Doing this stops the page jump, but also stops the sound! Code:
if(e.preventDefault){My html Code:
<div id="audioPlay" onclick="playSound();">LT |
Just move the focus to where you want it in the playSound function!
Example: Code:
<a name="backHere"></a> |
By the by, a sneaky way I do this:
Code:
<a href="someFile.wav" target="hiddenFrame"> Play sound </a>Code:
<a href="playSound.html?file=someFile.wav" target="hiddenFrame"> Play sound </a> |
Hi OP
I've tried method one in several ways and none of them worked. The page just jumps to bottom. Even though the url changes it doesn't go to the anchor. method one: Code:
<a name="backHere"></a>This embed gets the file from google --- I send word, it sends back sound, so I don't have an actual sound file. Could I use the embed with the iFrame? LT |
Sure, I use <embed> with the IFrame, in fact.
|
Hi OP
After some trial and lots of error I finally got it using your iframe method. Thanks LT |
Just to be a little pedantic, Old Pedant: the name attribute is not allowed on any element other than form controls. Named anchors are way outdated and I would be happy if you wouldn’t promote this practice so that newbies don’t get off on the wrong foot. Instead of
name, id should be used.The embed element is a different matter that would require a deeper discussion. |
Hmmm...If I use an ID for the <iframe> then can target= in the <a> tag "find" it? I've never tried that.
Actually, in my own code, I do use an ID for the <iframe> and then do Code:
document.getElementById("hiddenFrame").src = |
| All times are GMT +1. The time now is 04:09 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.