SitePoint Sponsor |
|
User Tag List
Results 1 to 25 of 32
Thread: I've been asking and asking
-
Jul 7, 2007, 12:32 #1
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I've been asking and asking
I've been to three other forums and they were anly able to help me a bit.
see some one gave me this code it works well but I wanted to add something else. what I added should work but wont. I got a bit of help from another forum and they were able to find out if the href value from the clicked links made it to the var retry. Turns out it's undefined unless it's window.retry
but it still seams that the player doesn't get the value.
here's the code. I was worrkied it wasnt set up right.
code I was givven awile ago
what I added
the way I was told to set it up
<body>
<a class="linksclass2" href="http://www.fileden.com/files/2006/11/20/398972/lupe%20fiasco%20-%20kick%20push.mp3">
<script type="text/javascript">
action=new Object();
action.linksclass1=function(e){
var el=window.event&&window.event.srcElement? window.event.srcElement : e&&e.target? e.target : null;
var retry=el.href;
if(el)
alert(el.innerHTML);
return false;
}
action.linksclass2=function(){
document.getElementById("misterioProgram").style.display="block";
document.embeds["newE"]["src"] =retry ;
document.getElementsByTagName("param")[0].value =retry;
return false;
}
var theas=document.getElementsByTagName('a');
for (var i_tem = 0; i_tem < theas.length; i_tem++)
theas[i_tem].onclick=action[theas[i_tem].className];
</script>
<div id="misterioProgram">
<h1 id="vidh">the video page</h1>
<p id="vidp">it will take some time to load</p>
<div id="MTVplayer">
<object id="fileObj" width="300" height="450"
classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"
standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">
<param name="fileName" value="">
<param name="autoStart" value="true">
<param name="showControls" value="true">
<param name="loop" value="false">
<param name="uiMode" value="full">
<embed id="fileEmb" type="application/x-mplayer2"
src=""
ShowControls="1"
width="235"
height="160">
</embed>
</object>
</div>
<!--the big div-->
<div id="ChooseSeason" align="left" >
<!--the div of the navi-->
<div id="Mtt1" class="theSeasons">
<!--the div for teen titans season one Mtt one-->
<ul>
<li> Teen Titans Season 3 </li>
<a href="http://www.fileden.com/files/2006/11/20/398972/Seal%20-%20Kiss%20From
%20A%20Rose.mp3" onclick="misterio(); return false;"
>the end part one</a>
</ul>
</div> <!--end of the teen titans div-->
</div> <!--end of nav div-->
</div>
</body>
-
Jul 7, 2007, 13:18 #2
- Join Date
- Mar 2007
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Can you just state what you're trying to accomplish? That code is convoluted and difficult to understand (at least for me). So if you tell us what you want to do, we can try and come up with a better and simpler method.
-
Jul 7, 2007, 13:27 #3
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Yes, please do that. Also post the HTML in HTML highlighted code and the javascript in a separate Javascript syntax highlighted code block. This can be easily done in Reply advanced mode.
-
Jul 7, 2007, 13:49 #4
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
the object seasons find out of if a link's class is equal to linksclass2.
what iwas trying to do if have links from a particular class open a div and send their href value to a embed player. the player uses object and embed tags to be cross browser.
when I'm done I'm going to use a quicktime an windos media player detection script to switch players using an I frame so some wher in the script it will have some thing like this if (linkclasstwo && hasQt){do something}else if (linksclass2 &&hasWMP){do something else}
HTML Code:<html> <head> <head> <body> <a class="linksclass2" href="http://www.fileden.com/files/2006/11/20/398972/lupe%20fiasco%20-%20kick%20push.mp3">
Code JavaScript:<script type="text/javascript"> action=new Object(); action.linksclass1=function(e){ var el=window.event&&window.event.srcElement? window.event.srcElement : e&&e.target? e.target : null; var retry=el.href; if(el) alert(el.innerHTML); return false; } action.linksclass2=function(){ document.getElementById("misterioProgram").style.display="block"; document.embeds["newE"]["src"] =retry ; document.getElementsByTagName("param")[0].value =retry; return false; } var theas=document.getElementsByTagName('a'); for (var i_tem = 0; i_tem < theas.length; i_tem++) theas[i_tem].onclick=action[theas[i_tem].className]; </script>
HTML Code:<div id="misterioProgram"> <h1 id="vidh">the video page</h1> <p id="vidp">it will take some time to load</p> <div id="MTVplayer"> <object id="fileObj" width="300" height="450" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"> <param name="fileName" value=""> <param name="autoStart" value="true"> <param name="showControls" value="true"> <param name="loop" value="false"> <param name="uiMode" value="full"> <embed id="fileEmb" type="application/x-mplayer2" src="" ShowControls="1" width="235" height="160"> </embed> </object> </div> <!--the big div--> <div id="ChooseSeason" align="left" > <!--the div of the navi--> <div id="Mtt1" class="theSeasons"> <!--the div for teen titans season one Mtt one--> <ul> <li> Teen Titans Season 3 </li> <a href="http://www.fileden.com/files/2006/11/20/398972/Seal%20-%20Kiss%20From %20A%20Rose.mp3" onclick="misterio(); return false;" >the end part one</a> </ul> </div> <!--end of the teen titans div--> </div> <!--end of nav div--> </div> </body>
-
Jul 7, 2007, 14:11 #5
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I would do it like this:
Code Javascript:window.onload = function() { var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].className == 'movieloader') { // find links with class="movieloader" links[i].onclick = function(e) { // attach function to each if (window.event) window.event.returnValue = false; else e.preventDefault(); // stop browser from going to link href var mP = document.getElementById('misterioProgram'); mP.style.display = 'block'; mP.getElementsByTagName('embed')[0].src = this.href; mP.getElementsByTagName('param')[0].value = this.href; } } } }
That would go in your <head>. I think this is what you want to do.
-
Jul 7, 2007, 14:34 #6
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
if it send the value to the object and embed tags and it's cross browser, yes.
however how would I do this if the media player was in an Iframe.
I have one more question after this but I have to go.
-
Jul 7, 2007, 14:48 #7
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
It's cross-browser. It sends the contents of the href attribute of the link that was clicked to the object/embed tag. If it's in an iframe, you have to target it via the iframe's name, I think. I have little experience with frames or iframes.
-
Jul 8, 2007, 11:11 #8
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you should play around with this because in IE I get the error getElementsByTagName('....')[0] is null or not an object. That really getElementsByTagName('embed')[0]
in fire fox it plays the right thing. This is really strange. oh by the way in my old code it had other methods like if you want to have another link class dosomething else with out having to write out the same function so i just use more if else statements I really wish I could have turned this back in to an object but it will not work that was for some strange reason.
did you ever find out what was wrong with my old code.
Code:window.onload = function() { var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].className == 'movieloader') { /*find links with class="movieloader" */ links[i].onclick = function(e) { /* attach function to each */ if (window.event) window.event.returnValue = false; else e.preventDefault(); /*stop browser from going to link href */ var mP = document.getElementById('misterioProgram'); mP.style.display = 'block'; mP.framname.getElementsByTagName('embed')[0].src = this.href; mP.framename.getElementsByTagName('param')[0].value = this.href; } } }}
okay now for my last question. I have a quicktime dectection script. is there a way to attack it to the function so I can put a if statement between mP.style.display = 'block'; and the object and embed tads because i want to have it call one frame if lets say I have quicktime and another if I have WMP. here is the detection code. I'm worried I can't call another functions variable here.
Code JavaScript:<script type="text/javascript"> // create a multidimensional associative array to store our plugin names and datatypes $plugin_type = { 'SVG Viewer': { 'ieAndWin': 'Adobe.SVGCtl', 'nsOrMac': 'image/svg-xml' }, 'Shockwave Director': { 'ieAndWin': 'SWCtl.SWCtl.1', 'nsOrMac': 'application/x-director' }, 'Flash': { 'ieAndWin': 'ShockwaveFlash.ShockwaveFlash.1', 'nsOrMac': 'application/x-shockwave-flash' }, 'RealPlayer': { 'ieAndWin': 'rmocx.RealPlayer G2 Control.1', 'nsOrMac': 'audio/x-pn-realaudio-plugin' }, 'QuickTime': { 'ieAndWin': 'QuickTimeCheckObject.QuickTimeCheck.1', 'nsOrMac': 'video/quicktime' }, 'Windows Media Player': { 'ieAndWin': 'MediaPlayer.MediaPlayer.1', 'nsOrMac': 'application/x-mplayer2' }, 'Acrobat Reader': { 'ieAndWin': 'PDF.PdfCtrl.5', 'nsOrMac': 'application/pdf' }}; function detectPlugin( $inPluginName ){ var agt = navigator.userAgent.toLowerCase(); var ie = ( agt.indexOf('msie') != -1 ); var ns = ( navigator.appName.indexOf('Netscape') != -1 ); var win = ( ( agt.indexOf('win') != -1 ) || ( agt.indexOf('32bit') != -1 ) ); var mac = ( agt.indexOf('mac') != -1 ); $pluginEnabled = false; if( $inPluginName != 'Java' ) { if( ie && win ) { $pluginEnabled = detectIE( $plugin_type[$inPluginName]['ieAndWin'] ); } if( ns || !win ) { nse = ''; for( var i = 0; i < navigator.mimeTypes.length; i++ ) { nse += navigator.mimeTypes[i].type.toLowerCase(); } $pluginEnabled = detectNS( $plugin_type[$inPluginName]['nsOrMac'] ); } } else { $pluginEnabled = navigator.javaEnabled() ? true : false; } return $pluginEnabled ;} function detectNS( ClassID ){ n = ''; if( nse.indexOf( ClassID ) != -1 ) { if( navigator.mimeTypes[ClassID].enabledPlugin != null ) { return true; } else { return false; } }} function detectIE( ClassID ){ result = false; // this line needs to be broken to prevent errors in internet explorer, hence the strangeness in the middle of</SC' + 'RIPT> document.write( '<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject( CreateObject("' + ClassID + '") )</SC' + 'RIPT>' ); if( result ) { return true; } else { return false; }} // ========================================== // this portion determines what to do // =============================================== if( detectPlugin( 'QuickTime' ) == true ){QUIFrame()} else if( detectPlugin( 'Windows Media Player' ) == true ){WMPFrame()} else{read()}
HTML Code:<head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- #misterioProgram { background-color: #666666; display: none; position: absolute; z-index: 4; height: 400px; width: 400px; left: 200px; top: 200px; } --> </style> </head> <body> <a class="movieloader" href="http://www.fileden.com/files/2006/11/20/398972/lupe%20fiasco %20-%20kick%20push.mp3">clickhere </a> <script type="text/javascript"> window.onload = function() { var links = document.getElementsByTagName('a'); for (var i = 0; i < links.length; i++) { if (links[i].className == 'movieloader') { /*find links with class="movieloader" */ links[i].onclick = function(e) { /* attach function to each */ if (window.event) window.event.returnValue = false; else e.preventDefault(); /*stop browser from going to link href */ var mP = document.getElementById('misterioProgram'); mP.style.display = 'block'; mP.getElementsByTagName('embed')[0].src = this.href; mP.getElementsByTagName('param')[0].value = this.href; } } }} </script> <div id="misterioProgram"> <h1 id="vidh">the video page</h1> <p id="vidp">it will take some time to load</p> <div id="MTVplayer"> <object id="fileObj" width="300" height="450" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"> <param name="fileName" value=""> <param name="autoStart" value="true"> <param name="showControls" value="true"> <param name="loop" value="false"> <param name="uiMode" value="full"> <embed id="fileEmb" type="application/x-mplayer2" src="" ShowControls="1" width="235" height="160"> </embed> </object> </div> <!--the big div--> <div id="ChooseSeason" align="left" > <!--the div of the navi--> <div id="Mtt1" class="theSeasons"> <!--the div for teen titans season one Mtt one--> <ul> <li> Teen Titans Season 3 </li> <a href="http://www.fileden.com/files/2006/11/20/398972/Seal%20-% 20Kiss%20From%20A%20Rose.mp3" onclick="misterio(); return false;"> the end part one</a> </ul> </div> <!--end of the teen titans div--> </div> <!--end of nav div--> </div> </body> </html>
-
Jul 9, 2007, 16:31 #9
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Okay, okay but this will not work in IE. the last block of text is my whole page. but it's better if you download it because I've made some changes. I have no idea why it won't work. please I'm so close to having this 5 month problem fixed.
-
Jul 9, 2007, 16:49 #10
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
What, specifically, doesn't work? Your code is quite messy. Do you mean that when you click on the movieloader link the misterioProgram div does not show up?
-
Jul 9, 2007, 17:05 #11
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
nothing happend in IE it doesn't play. i get the error getElementsByTagName('....')[0] is null or not an object. on the line for getElementsByTagName('embed')[0]
aslso I can't seem to attach the detection script to the class name function. I find out how to fix it some how.
-
Jul 9, 2007, 17:14 #12
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I've just noticed you put the javascript in the <body> when I said it should go in the <head>. Perhaps that's the problem.
-
Jul 9, 2007, 17:24 #13
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I though that perhaps I needed to go under the links like my last code. but if it's to work cross browser It might not work correctly if it's in the body section?
by the way do you have IE?
-
Jul 9, 2007, 17:30 #14
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
It should work correctly if it's in the <head>. That's what the window.onload { } stuff is for. If you put it in the body that's not necessary, but javascript should go in the <head> anyway. That's it's proper place.
Yes, I have IE6.
-
Jul 10, 2007, 07:24 #15
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
done but it's still not working with the Iframes....hum
-
Jul 10, 2007, 15:48 #16
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Spelling error?
Code:mP.framname.getElementsByTagName('embed')[0].src = this.href;
-
Jul 10, 2007, 16:27 #17
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
mP.playerframe.getElementsByTagName
its been changed. I thought I sent the right file. okay I see something really dumb but I will send you all the files. because this should work.
I think the Javascript order maynot be right or something
-
Jul 10, 2007, 16:40 #18
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
What is mP? I have no experience referencing other frames, but I thought that if the frame has name="playerframe" doing playername.propertyis like doing window.property in that scope, so that's how you reference frames. So there shouldn't be any parent object to it (like this "mP" thing).
-
Jul 10, 2007, 16:41 #19
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
oh...yeah I guess that is true. I'll see if it works.
no it doesn't work that way. I still think I have something set up wrong.Last edited by riptide; Jul 10, 2007 at 16:51. Reason: checked
-
Jul 10, 2007, 16:44 #20
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
OK I see now:
Code:var mP = document.getElementById('misterioProgram'); mP.framename.getElementsByTagName('embed')[0].src = this.href; mP.framename.getElementsByTagName('param')[0].value = this.href;
Code:framname.mP.getElementsByTagName('embed')[0].src = this.href; framename.mP.getElementsByTagName('param')[0].value = this.href;
-
Jul 10, 2007, 17:20 #21
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
no that's not it. I don't know how to set this part up. but i think he have had it right at some point. I really think something is wrong like how i'm using the detection varibles.
but I do see something document.iframe["iFrame"] I'm not sure if that is how it's to workLast edited by riptide; Jul 10, 2007 at 17:27. Reason: adding
-
Jul 10, 2007, 17:23 #22
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
When you set mP, it's in the current scope. You probably have to do this:
Code:framename.document.getElementById('misterioProgram').getElementsByTagName('embed')[0].src = this.href;
Give this a read: http://www.quirksmode.org/js/iframe.html
OK, looks like you need to do this:
Code:frames['framename'].document.getElementById('misterioProgram').getElementsByTagName('embed')[0].src = this.href;
-
Jul 10, 2007, 17:35 #23
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
well I was looking for something like that. however even thoug this most likely works the problem seemes to be some where in how the detection script is connected to the classname function I think
if( detectPlugin( 'QuickTime' ) == true )
part is not connected right. maybe I should be putting this function into another function. I don't know how to set that part up.
-
Jul 11, 2007, 04:21 #24
- Join Date
- Sep 2005
- Location
- Tanzania
- Posts
- 4,662
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Me neither. I've never played about with these plugins.
-
Jul 11, 2007, 07:37 #25
- Join Date
- Jul 2007
- Posts
- 19
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
okay I'm going to see if I can get some help. I've moved the script around and still I'm running into problems.
detectPlugin( 'QuickTime' ) == true ) is where I think the issue is.
Bookmarks