I have a embedded code which displays yahoo chart
the embedded code is -
<embed bgcolor="#dbdbd3" flashvars="lcId=1169793726234&state=symbol%3D%5Ensebank;range=1d;indicator=ema(13,34,55)+macd+rsi+stochasticfast;charttype=candlestick;crosshair=on;ohlcvalues=0;logscale=on;source=undefined" loop="false" menu="false" name="BANKNIFTY" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://us.js2.yimg.com/us.yimg.com/i/us/fi/yfc/swf/flashchart_1.18.swf" style="height: 775px; width: 550px" type="application/x-shockwave-flash" wmode="opaque"></embed>
I want this embedded code to be displayed when I click on the display button.
Please suggest the relevant javascript.
I tried something like this
<script type="text/javascript">
function ln(){
document.getElementById('looknorth').innerHTML='<embed bgcolor="#dbdbd3" flashvars="lcId=1169793726234&state=symbol%3D%5Ensebank;range=1d;indicator=ema(13,34,55)+macd+rsi+stochasticfast;charttype=candlestick;crosshair=on;ohlcvalues=0;logscale=on;source=undefined" loop="false" menu="false" name="BANKNIFTY" pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://us.js2.yimg.com/us.yimg.com/i/us/fi/yfc/swf/flashchart_1.18.swf" style="height: 775px; width: 550px" type="application/x-shockwave-flash" wmode="opaque"></embed>'();
}
</script>
<input type=button style="background-color:#123742; color:#FFFFFF ; font-weight:bold; font-size:15" name=Button2 value=Calculate onClick=ln();></td></tr>
by referring to a code found on the internet but is not working.
This line need to be edited:
document.getElementById('looknorth').innerHTML='<embed ....</embed>'();
To:
document.getElementById('looknorth').innerHTML='<embed ....</embed>';
the parantheses are not supposed to be there, because the string is not a function.
Create a div with the said id first then add the content to it:
<div id="looknorth"></div>
<script type="text/javascript">
function ln(){
document.getElementById('looknorth').innerHTML='<embed....></embed>';
}
</script>
<input type="button" value="Show Chart" onClick="ln();" />
Related
I have no HTML knowledge, I just have a simple task that I can't seem to grasp the concept of doing.
I want to take a url parameter and pass it to a swf object. I've figured out getting the parameter via javascript, but getting that return string to the object is my issue.
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
return "http://www.Twitch.tv/swflibs/TwitchPlayer.swf?channel=twitch";
}
</script>
Link Example
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="800" height="600" id="mymoviename">
<embed src="#" onload="this.src=myFunction()" quality="high" bgcolor="#ffffff"
width="800" height="600"
name="mymoviename" align="" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
</body>
</html>
Markup based on Suggested answer(still does not work)
<!DOCTYPE html>
<html>
<body>
Link Example
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
width="800" height="600" id="mymoviename">
<embed src="#" quality="high" bgcolor="#ffffff" width="800" height="600"
name="mymoviename" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>
<script>
function myFunction() {
return "http://www.Twitch.tv/swflibs/TwitchPlayer.swf?channel=twitch";
}
document.getElementById('mymoviename').src = myFunction();
</script>
</body>
</html>
You can do it by following the following steps.
Move your <script> to just before </body>
And add the below code in <script>:
Code:
function myFunction() {
return "http://www.Twitch.tv/swflibs/TwitchPlayer.swf?channel=twitch";
}
document.getElementById('mymoviename').src = myFunction();
I found this article:
http://www.permadi.com/tutorial/flashVars/
Instead of passing the javascript variable to html markup, just write the markup with the script itself. Here is the working code:
<HTML><HEAD><TITLE>Example</TITLE></HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--
var myQueryString=document.location.search;
// remove the '?' sign if exists
if (myQueryString[0]='?')
{
myQueryString=myQueryString.substr(3, myQueryString.length-1);
}
document.write(
'<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://macromedia.com/cabs/swflash.cab#version=6,0,0,0" WIDTH="250" HEIGHT="250" id="flaMovie1"> <embed src="'+myQueryString+'" quality="high" bgcolor="#ffffff" width="800" height="600" name="mymoviename" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n'+
'</embed>\n'+
'</OBJECT>');
</SCRIPT>
</BODY>
</HTML>
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 have 2 swf in my html page which are video and popup. When mouse over to video.swf the hidden popup.swf will show and play.
<body>
<object id="video" class="video" width="300" height="250">
<param name="movie" value="thumbnail.swf">
<embed src="thumbnail.swf" quality="high" width="300" height="250" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
</object>
<img class="image" src="300x250.jpg">
<object id="popup" class="popup" width="790" height="290">
<param name="movie" value="790x290.swf">
<embed src="790x290.swf" width="300" height="250"> </embed>
</object>
<script>
document.getElementById("video").onmouseover = over;
(function over()
{
alert("mouseovertest");
});
</script>
The mouseover on video.swf is working fine but Im not sure how to make the popup.swf shows and play.
put this in your <script> section:
document.getElementById("popup").onmouseover = over;
How can I make JavaScript loop left all <object> elements and hide them?
var objects = document.getElementsByTagName('object');
for (var i=0, n=objects.length;i<n;i++) objects[i].style.display='none';
Update. Playing with something I had thought about before. It works in Fx with object, but although I could make it work in IE with divs, I could not make it work in IE - not even with classnames on the object.
<html>
<head>
<title></title>
<style type="text/css">
object {
display:block;
}
</style>
<script type="text/javascript">
// got some of this from http://www.javascriptkit.com/dhtmltutors/externalcss3.shtml
function toggle() {
var mysheet=document.styleSheets[0]
var firstrule=mysheet.cssRules? mysheet.cssRules[0]: mysheet.rules[0]
firstrule.style.display=(firstrule.style.display=="block")?"none":"block"
return false
}
</script>
</head>
<body>
toggle the objects<br />
<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/tgbNymZ7vqY?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/tgbNymZ7vqY?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/VnT7pT6zCcA?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/VnT7pT6zCcA?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/PhMCa1_9FYg?fs=1&hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/PhMCa1_9FYg?fs=1&hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
</body>
</html>
I think you can do this with something like this css-rule:
html object { display: none; }
instead of javascript.
or use a class + javascript
html object.no-show { display: none; }
and use a loop to apply the class on all objects.
or toggle the class to the body:
html body.hide-object object { display: none; }
this is with javascript with no loop.
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