I'm attempting to creating a music player that plays a random song by choose a random item from an array and setting it and other things, via concatenation, as the embed's src.
<script type="text/javascript">
//Playlist
var musicArray = ['b.mp3', 'b2.mp3', 'b3.mp3'];
//src vars
var first = 'niftyplayer.swf?file=';
var last = '&as=1';
// Shuffle
var mid = musicArray[Math.floor(Math.random() * myArray.length)];
//Set src
getElementById("embed").src='first+mid+last';
getElementById("param").value='first+mid+last';
</script>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0, 0" width="165" height="38" id="niftyPlayer1" align="">
<param id="param" name=movie value="">
<param name=quality value=high>
<param name=bgcolor value=#FFFFFF>
<embed id="embed" src="" quality=high bgcolor=#FFFFFF width="165" height="38" name="niftyPlayer1" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<script type="text/javascript" language="javascript" src="niftyplayer.js"></script>
However, my script does not work.
JSFiddle of niftyplayer.js
In this case, load js after html.
Then, fix your 'embed' and 'param'.
-- code below.
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0, 0" width="165" height="38" id="niftyPlayer1" align="">
<param id="param" name=movie value="">
<param name=quality value=high>
<param name=bgcolor value=#FFFFFF>
<embed id="embed" src="" quality=high bgcolor=#FFFFFF width="165" height="38" name="niftyPlayer1" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<script type="text/javascript" language="javascript" src="niftyplayer.js"></script>
<script type="text/javascript">
//Playlist
var musicArray = ['b.mp3', 'b2.mp3', 'b3.mp3'];
//src vars
var first = 'niftyplayer.swf?file=';
var last = '&as=1';
// Shuffle
var mid = musicArray[Math.floor(Math.random() * myArray.length)];
//Set src
getElementById("embed").src = first + mid + last;
getElementById("param").value = first + mid + last;
</script>
Put the javascript code after html, and remove quotes from below lines 'first+mid+last'
getElementById("embed").src= first+mid+last;
getElementById("param").value= first+mid+last;
Related
I am trying to print the my whole website, normally the background turns white which is good, but i cant get the background color of an element to change to white to save ink.
This is the code
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="900" height="700" id="Kirchhoff" align="middle">
<param name="movie" value="Kirchoff.swf">
<param name="quality" value="high">
<param name="wmode" value="opaque">
<param name="bgcolor" value="#ffffff">
<embed src="Kirchhoff.swf" quality="high" bgcolor="#DDB85F" width="900" height="700" name="Kirchhoff" align="middle" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" />
<br>
and this it the print code so far
SCRIPT LANGUAGE="JavaScript">
if (window.print) {
document.write('<form> '
+ '<input type=button name=print value="Imprimir" '
+ 'onClick="javascript:window.print()"></form>');
}
</script>
You should do this with CSS, not JavaScript.
#media print{
.element {
background-color: white;
}
}
#JoshSpears this would be the new one
<link rel="stylesheet" href="styles.css">
</head>
<body bgcolor="#7CF8EC">
<br>
<br>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="900" height="700" id="Kirchhoff" align="middle">
<param name="movie" value="Kirchoff.swf">
<param name="quality" value="high">
<param name="wmode" value="opaque">
<param name="bgcolor" value="#ffffff">
<embed src="Kirchhoff.swf" quality="high" bgcolor="#DDB85F" width="900" height="700" name="Kirchhoff" align="middle" allowScriptAccess="sameDomain" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" />
<br>
<center><SCRIPT LANGUAGE="JavaScript">
if (window.print) {
document.write('<form> '
+ '<input type=button name=print value="Imprimir" '
+ 'onClick="javascript:window.print()"></form>');
}
</script>
</center>
</body>
</html>
Am working on a flash slider.I have 2 images embeded in it.. is it possible to click on the images and load a new html page?Here is my code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="308" height="118" title="location">
<param name="movie" value="<?=base_url()?>flash/home/locationsliders.swf">
<param name="quality" value="high">
<embed src="<?=base_url()?>flash/home/locationsliders.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="308" height="118" ></embed>
</object>
<script type="text/javascript">
AC_FL_RunContent('codebase',
'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','308','height',
'118','title','location','src',
'<=base_url()>flash/home/locationsliders',
'quality','high','pluginspage',
'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash',
'movie','<?=base_url()?>flash/home/locationsliders' ); //end AC code
</script>
I'm trying to extract javascript code from a textarea here is my code:
def getCode(self,request):
#print "Extracting URL: " + request
opener = self.login(self.username,self.password)
html = etree.HTML(opener.open(request).read())
textarea = html.xpath('//*[#id="codeText"]/text()')
for code in textarea:
return code
This is the html code I'm trying extract from:
<textarea onclick="javascript: this.select();" id="codeText" style="height: 300px;width:500px;"> <!-- Clickon Affiliate code start here -->
<object type="application/x-shockwave-flash" data="http://banners.clickon.co.il/LOVELY2_banners/swf/JWFLZxzNxjclWGP.swf?url=http://track.clickon.co.il/click/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" width="728" height="90">
<param name="movie" value="http://banners.clickon.co.il/LOVELY2_banners/swf/JWFLZxzNxjclWGP.swf?url=http://track.clickon.co.il/click/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" />
<param name="scale" value="exactfit" />
<param name="wmode" value="transparent" />
</object>
<img alt="" style="visibility: hidden;" src="http://track.clickon.co.il/imp/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" />
</textarea>
if the textarea contain only links or a text my getCode function working great, but if it contains java script code I cant extract it.
Can you help me ?
Thanks,
Yaniv.
In the code, for loop return too early; return only the first text.
If you want all the tags and text, try following.
import lxml.etree as etree
htmlchunk = '''
<textarea onclick="javascript: this.select();" id="codeText" style="height: 300px;width:500px;"> <!-- Clickon Affiliate code start here -->
<object type="application/x-shockwave-flash" data="http://banners.clickon.co.il/LOVELY2_banners/swf/JWFLZxzNxjclWGP.swf?url=http://track.clickon.co.il/click/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" width="728" height="90">
<param name="movie" value="http://banners.clickon.co.il/LOVELY2_banners/swf/JWFLZxzNxjclWGP.swf?url=http://track.clickon.co.il/click/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" />
<param name="scale" value="exactfit" />
<param name="wmode" value="transparent" />
</object>
<img alt="" style="visibility: hidden;" src="http://track.clickon.co.il/imp/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" />
</textarea>
'''
html = etree.HTML(htmlchunk)
textarea, = html.xpath('//*[#id="codeText"]')
print(textarea.text + ''.join(etree.tostring(code) for code in textarea) + textarea.tail)
output:
<!-- Clickon Affiliate code start here -->
<object type="application/x-shockwave-flash" data="http://banners.clickon.co.il/LOVELY2_banners/swf/JWFLZxzNxjclWGP.swf?url=http://track.clickon.co.il/click/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS" width="728" height="90">
<param name="movie" value="http://banners.clickon.co.il/LOVELY2_banners/swf/JWFLZxzNxjclWGP.swf?url=http://track.clickon.co.il/click/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS"/>
<param name="scale" value="exactfit"/>
<param name="wmode" value="transparent"/>
</object>
<img alt="" style="visibility: hidden;" src="http://track.clickon.co.il/imp/Q8uTE8BXZz1pskj/JWFLZxzNxjclWGP/TsQ8uTE8BXZz1pskjtS"/>
I am trying to call a Jscript function from a flash object. I want the function to be called when the animation ends.
Here is the embed code
<h1 align="center">
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="360" HEIGHT="250" id="Yourfilename" ALIGN="center">
<PARAM NAME=movie VALUE="newbanner.swf">
<PARAM NAME=quality VALUE=high/><param name="LOOP" value="false" />
<param name="allowscriptaccess" value="always" />
<param name="wmode" value="transparent">
<param name="bgcolor" value="#FFFFFF">
<EMBED src="newbanner.swf" quality="high" bgcolor="#FFFFFF"
WIDTH="360" HEIGHT="250" loop="false" NAME="newbanner.swf" ALIGN=""
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
</h1>
here is the jScript function i want to call:
<script language="javascript">
function mainFunction() {
var mydiv = document.getElementById('content');
mydiv.innerHTML = "hello";
}
</script>
here is the action code I add to the last frame of the flash object
URLLoader("javascript:mainFunction();");
The object loads but the function is not called. I can call the function other ways such as using an "onclick = mainFunction()" event on a button for example. Where am i going wrong?
thanks in advance.
Why don't you use flash.external.ExternalInterface.call ?
Is there a Flash MP3 player that would allow me to do following to pass URL to mp3 file and get it automatically played. To help out with answer - here is detailed code that describes what I would like to do:
<object id="mp3PlayerSwf" type="application/x-shockwave-flash" data="mp3Player.swf">
<param name="movie" value="mp3Player.swf">
</object>
<input type="button" id="soundPlay1" value="Sound Play 1" />
<script type="text/javascript">
function eventHandler1(sender) {
var mp3Player = document.getElementById("mp3PlayerSwf");
mp3Player.playSound("http://myUrl.com/my.mp3");
}
var soundPlay1 = document.getElementById('soundPlay1');
if (soundPlay1.addEventListener) {
soundPlay1.addEventListener('click', eventHandler1, false);
}
// IE
else if (soundPlay1.attachEvent) {
soundPlay1.attachEvent('onclick', eventHandler1);
}
</script>
Constraint is that I can't use libraries that have JavaScript initialization - like for example SoundManager2 - http://www.schillmania.com/content/projects/soundmanager2/
Thanks for any help!
Try dewplayer: http://www.alsacreations.fr/dewplayer-en
You can use it like this (sample code taken from the link):
<object type="application/x-shockwave-flash" data="dewplayer.swf" width="200" height="20" id="dewplayer" name="dewplayer">
<param name="movie" value="dewplayer.swf" />
<param name="flashvars" value="mp3=test.mp3" />
<param name="wmode" value="transparent" />
</object>
Another player would be http://musicplayer.sourceforge.net