PDA

View Full Version : help deactivate javascript OnMousOver



turkiyem.fm
12-20-2008, 03:20 PM
hi all, i am hoping if someone could help me out with my problem here

help would be really appreciated.

I got a script written by someone for me and can't reach to him anymore and I need this to be fixed.

the problem is that the script works when the page is loaded so when i try to visit a link the url will automaticly go into the player.

If possible i would like to activate the javascript onMouseOver="init()" and deactivate it onMouseOut="clear()"

example <a href="#" onMouseOver="init()" onMouseOut="clear()"></a> or in a <div>

JavaScript
=========================
radio.js
=========================

window.onload = init();
function init () {
var x = document.getElementsByTagName ('a');
for (i = 0; i < x.length; i++) {
x[i].onclick = function () {
document.getElementById('below').innerHTML = "<embed type='application/x-mplayer2' id='music2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='"+ this.href +"' name='MediaPlayer1' width='217' height='84' controltype='1' showcontrols='1' showstatusbar='0' AutoStart='true'></embed> ";
return false;
}
}
}

HTML
======================
index.html
======================

<a href="mms://strm-4.us.media.tv/KRALFM_64?MSWMExt=.asf" onMouseOver="init()" onMouseOut="clear()"></a>
<embed
type="application/x-mplayer2"
id="MediaPlayer1"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
src=""
name="MediaPlayer1"
controltype="1"
showcontrols='1'
showstatusbar="0"
autostart="1"
height="84"
width="217" /> </embed>

magicyte
12-20-2008, 05:17 PM
window.onload = init();
function init () {
var x = document.getElementsByTagName ('a');
for (i = 0; i < x.length; i++) {
x[i].onclick = function () {
document.getElementById('below').innerHTML = "<embed type='application/x-mplayer2' id='music2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='"+ this.href +"' name='MediaPlayer1' width='217' height='84' controltype='1' showcontrols='1' showstatusbar='0' AutoStart='true'></embed> ";
return false;
}
}
}

function clear() {
var x = document.getElementsByTagName ('a');
for(i = 0; i < x.length; i++) {
x[i].onclick = function () {
document.getElementById('below').innerHTML = "";
return false;
}
}
}

Your post and code is very hard to understand. Just by inference, I made the .js have a function that you want. The 'onclick' handler you put in the code will most likely flag a compatibility error in differing browsers. I'll leave it like that for now. As for later, you may want to look into the "attachEvent" or "attachEventHandler" [<- is that correct?] attributes. Your HTML just wasn't working either:


<a href="mms://strm-4.us.media.tv/KRALFM_64?MSWMExt=.asf" onMouseOver="init()" onMouseOut="clear()"></a>
<span id="below"></span>

I'm really lost. Please provide some more clarification so that we can help you out.

-magicyte

turkiyem.fm
12-20-2008, 06:48 PM
thnx for your response magicyte, i tryed your script didn't work. my javascript knowledge is below the basics =/..eh..

yeah the url I gave is broken sorry, i got a new link mms://94.75.222.9/PowerTurk,

..I try to explain it again.
this one guy wrote a script for me

radio.js
=========================
//javascript


window.onload = init();
function init () {
var x = document.getElementsByTagName ('a');
for (i = 0; i < x.length; i++) {
x[i].onclick = function () {
document.getElementById('below').innerHTML = "<embed type='application/x-mplayer2' id='music2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/' src='"+ this.href +"' name='MediaPlayer1' width='217' height='84' controltype='1' showcontrols='1' showstatusbar='0' AutoStart='true'></embed> ";
return false;
}
}
}

index.html
==========
//embed Mediaplayer in html



<a href="mms://94.75.222.9/PowerTurk" ><div>image</div></a>

<div id="below">
<div id="mediaplayer" align="center">
<embed
type="application/x-mplayer2"
id="MediaPlayer1"
pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
src=""
name="MediaPlayer1"
controltype="1"
showcontrols='1'
showstatusbar="0"
autostart="1"
height="84"
width="217" ></embed>
</div>
</div>

only problem is that it gets loaded or activated together with your site. now i tried to adjust it a bit so that the script gets activated when clicked on or with MouseOver.
So I deleted the first line

window.onload = init();
after that i made the following link to activate the javascript manually to by hovering over a link


<a href="mms://94.75.222.9/PowerTurk" onMouseOver="init()" ><div>image</div></a>
by fixing 1 problem I created another problem =/
the problem is that all the other links when clicked on the window gets send to the embed mediaplayer like http://www.google.nl.

I just want that when I click on http://www.google.nl I go to the google page and when I click on radio link, it gets loaded by the embed mediaplayer on my site