PDA

View Full Version : jscheuer1, I need help with the object you gave me



riptide
05-20-2007, 08:40 PM
remember when I wanted to use a get element by class name function and you gave me an object to do what I was looking for.

well I'm kinda confused about something

<script type="text/javascript">
var action=new Object();
action.linksclass1=function(e){
var el=window.event&&window.event.srcElement?
window.event.srcElement : e&&e.target? e.target : null;
if(el)
alert(el.innerHTML);
return false;
}
action.linksclass2=function(){
document.getElementById("misterioProgram").style.display="block";
setAttribute("src", .getAttribute("href")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>

you see I have this other code in my site. I got this from another forum. it was an cross browser script of a music player. it sends a value from a select object to the src. I thought I could use it to collect the herf value of any link in one of the classes above and send it to the players src so it could be played.It's sitting in the head of my page.


function song(){
document.getElementById('MTVplayer').innerHTML="<embed type='application/x-mplayer2'
id='music2' pluginspage='http://www.microsoft.com/Windows/MediaPlayer/'
src='' name='MediaPlayer1' width='300' height='75' controltype='2'
showcontrols='1' showstatusbar='1' AutoStart='true'></embed>";


}


<div id="MTVplayer">
<object width="335" height="460"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
<param name="URL" value="">
<param name="AutoStart" VALUE="True">
<param name="uiMode" value="full">
<embed type="application/x-mplayer2"
src=""
ShowControls="1"
width="235"
height="160">
</embed>
</object>
</div>

there is no error but it won't play is there a way to capture the href value of the clicked link of those classes and send it to the player?

jscheuer1
05-20-2007, 09:08 PM
I will try to get a chance to look over this again, but as I recall you were pretty confused back then with that other thread and it appears that you are here as well. The red highlighted part of your code is nonsense as far as I can tell:


setAttribute("src", .getAttribute("href")

Both setAttribute() and getAttribute() require objects (these are most often if not exclusively HTML elements) that they will 'act on' in the form of:


object.setAttribute('attribute_name', 'attribute_value', 0);

and:


object.getAttribute('attribute_name', 0);

They can be combined somewhat like what you have:


object.setAttribute('src', another_object.getAttribute('href', 0), 0);

However, not all browsers will necessarily see the src and href attributes as qualifying for a get and set in this manner. Testing would be required to verify that the code is executing properly. Generally, you can do the same thing like so though:


object.src=another_object.href;

But, since multimedia tags appear to be involved, this approach should also be tested before being relied upon. And, if <param> elements of an <object> tag are also what you want to set or get, you must get them as javascript HTML element objects, not just their parent <object> tag elements.

Note: The 0's are just to satisfy a rare but sometimes essential requirement in IE.

Bob90
05-21-2007, 07:37 AM
Waht is the rare, but soemtimes essential occurance?

I used it before in IE and It didn't work as expected.

jscheuer1
05-21-2007, 09:24 AM
Waht is the rare, but soemtimes essential occurance?

I used it before in IE and It didn't work as expected.

It is a flag value as regards case sensitivity in the method. 0 tells the browser that src, Src and SRC should all be considered the same. Using a 1 makes the attribute name case sensitive. This distinction can be especially important when acting upon an element generated via innerHTML, as the browser chooses the case for attribute names when writing it.

But, even when you use this case-insensitive flag, IE doesn't always implement getAttribute() and setAttribute() properly.

See:

http://msdn2.microsoft.com/en-us/library/ms536429.aspx

riptide
05-21-2007, 02:37 PM
I'm sorry I for got to put id tags in the object,embed and param.

I really have read all kinds of problems with trying to set the attributes of param.

so lets say paramname.setAttribute("src", .getAttribute("href","?"))
wouldn't work. as far as I have read. so (object.src=another_object.href) may work better in a crossbrowser script.

but the big problem is the .getAttribute set up.

I'm tying to get linksclass2 and other link classes that I add, to send their href value to the param and embed when clicked. I'm trying to add this to your object (action's) methods

riptide
05-22-2007, 12:42 AM
wait I just realized something.

my original code used two plugin detection functions.

the first one was to detect quicktime. if there wasn't quicktime it calls a function to detect for windows media player.

when it finds something you have I was going to use document.write to write out the object and embed tags for each kinda player. but when I tried it, it never worked. even a site that told you how to do it really just wrote it the normal way.

the problem is because I can't have a function to write it out depending on the plugin test; how do I send the links href value to the right object embed tag because I need to have one for windows and one for quicktime on the page.

jscheuer1
05-22-2007, 04:41 AM
That's not really my department. But, offhand, I would say just use Flash and forget about the other two. Flash is just better than either of those two and almost everybody has it.

Futzing about with any type of multimedia tag via script is tricky. Each browser reacts differently. For any real design control over multimedia objects I prefer to use the multimedia application itself - say, if using Flash, program the playlist or whatever into the .swf. The only other method that I've found that is reliable is to rotate different objects on separate pages via an iframe on the main page.

riptide
05-22-2007, 02:35 PM
well I really know nothing about flash and it's script. I really hate working with that application even for the smallest things. But scripting media players is a pain and I'm going through it with something else. I can use the detection script to change an Iframe but I still need to be able to send the href values from the clicked links to the players.

I think if I can do that I can fumble around with how to get it to work right.

riptide
05-24-2007, 12:53 AM
when you have the time can you help me out with this. I'm going to end up using Iframes.

riptide
05-25-2007, 02:37 PM
I thought to try something else I saw. trying to send the value of the clicked link to the object and embed tags. I'm not getting an error but it still dosen't work. should I be putting some of the dark red part in the object and embed tags.




<div id="watchShows">
<p id="thestuff">shows</p>
<img/>
<p>Teen Titans</p>
<p> season three</p>
<ul id="TT">
<li><a class="linksclass2" href="http://www.knallgrau.at/code/plugin_js/demo/video-embeding/files/skifoan.mov" return false >
the end part one open misterio</a></li>
<li><a class="linksclass3" href="#" onclick="">the classes </a></li>
</ul>



<script type="text/javascript">
var action=new Object();
action.linksclass1=function(e){
var el=window.event&&window.event.srcElement?
window.event.srcElement : e&&e.target? e.target : null;
var linkValue = (el.target || el.srcElement).href;
if(el)
alert(el.innerHTML);
return false;
}
action.linksclass2=function(){
linkValue=document.getElementById("mainP").value;
linkValue=document.getElementById("mainP").value
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="MTVplayer">
<object width="335" height="460"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
<param id="mainP" name="URL" value="">
<param name="AutoStart" VALUE="True">
<param name="uiMode" value="full">
<embed id="theE" type="application/x-mplayer2"
src=""
ShowControls="1"
width="235"
height="160">
</embed>
</object>
</div>