riptide
07-24-2007, 10:42 AM
I need some javascript help. i've gone to a few other forums but I really just need help fixing a code. I was told to come to this forum by a friend.
I have a script. it checks if you have WMp or quicktime. if you have quicktime it makes an iframe for the WMP or quicktime object. it also checks if a link you clicked belongs to a class if so it takes the href value and sends it to the WMP or quicktime objects src and filename values.
the problem is I think getting the file name part to use the detection function.
here is the code.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
/*if you have windows media player*/
function WMPFrame() {
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "WMPIframe.html");
iframe.setAttribute("id", "playerframe");
iframe.setAttribute("scrolling", "no");
iframe.setAttribute("frameBorder", "0");
iframe.setAttribute( "width", "200" );
iframe.setAttribute( "height", "200" );
document.body.appendChild(iframe);
}
/*if you have quicktime*/
function QUIFrame() {
var Frame = document.createElement("iframe");
Frame.setAttribute("src", "QuicktimeIfram.html");
Frame.setAttribute("id", "timeframe");
Frame.setAttribute("scrolling", "no");
Frame.setAttribute("frameBorder", "0");
Frame.setAttribute( "width", "200" );
Frame.setAttribute( "height", "200" );
document.body.appendChild(Frame);
}
/*if you have no plugins*/
function read(){
var answer = confirm ("Please click on OK to continue loading my page,
or CANCEL to be directed to the Yahoo site.")
if (answer)
var MKDIV = document.createElement( 'div' );
MKDIV.setAttribute('id','pluginsite');
MKDIV.style.backgroundColor="#F0CCF0";
MKDIV.style.border = '1px solid blue';
MKDIV.style.left = '35%'
MKDIV.style.top = '200px'
MKDIV.style.width = '300px'
MKDIV.style.heigh = '200px'
MKDIV.style.font = '14px arial #FF6666'
MKDIV.style.position='absolute'
document.getElementsByTagName( 'body' )[0].appendChild( MKDIV );
MKDIV.appendChild(document.createTextNode("To download quick time \u00a0 "))
var lQT=document.createElement('a');
lQT.setAttribute('href','http://www.apple.com/qtactivex/qtplugin.cab' );
lQT.appendChild( document.createTextNode( 'QuickTime' ) );
MKDIV.appendChild(lQT);
MKDIV.appendChild(document.createTextNode("\u00a0 or go to windows media player's download page \u00a0"));
var lWMP=document.createElement('a');
lWMP.setAttribute('href','http://www.microsoft.com/windows/windowsmedia/
download/AllDownloads.aspx' );
lWMP.appendChild( document.createTextNode( 'WMP' ) );
MKDIV.appendChild(lWMP);
window.setTimeout("stopdiv();", 12000)
}
function stopdiv ( )
{
document.body.removeChild(document.getElementById( 'pluginsite'))
}
/*end of no plugin and Iframes.*/
</script>
<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>
<script type="text/javascript">
</script>
<a class="linksclass2" href="#">click</a>
<a class="linksclass2" href="http://www.fileden.com/files/2006/11/20/398972/
lupe%20fiasco%20-%20kick%20push.mp3" return="false">clickhere </a>
<script type="text/javascript">
$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()}
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 (window.event) window.event.returnValue = false; else e.preventDefault();
if(el)
alert(el.innerHTML);
return false;
}
action.linksclass2=function(){
document.getElementById("misterioProgram").style.display="block";
if(detectPlugin( 'QuickTime' ) == true ){
frames['timeframe'].document.getElementsByTagName('embed')[0].src = this.href;
frames['timeframe'].document.getElementsByTagName('param')[0].value = this.href;}
else if (detectPlugin( 'Windows Media Player' ) == true ){
frames['playerframe'].document.getElementsByTagName('embed')[0].src = this.href;
frames['playerframe'].document.getElementsByTagName('param')[0].value = this.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>
<div id="misterioProgram">
<h1 id="vidh">the video page</h1>
<p id="vidp">it will take some time to load</p>
<div id="MTVplayer">
</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>
quicktime iframe
<body>
quicktime Iframe
<OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'
width='320' height='240' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>
<param name='src' value=''>
<param name='autoplay' value='true'>
<param name='controller' value='true'>
<param name='loop' value='false'>
<EMBED src='' width='320' height='240' autoplay='true'
controller='true' loop='false' bgcolor='#000000' pluginspage='http://www.apple.com/quicktime/download/'>
</EMBED>
</OBJECT>
</body>
I have a script. it checks if you have WMp or quicktime. if you have quicktime it makes an iframe for the WMP or quicktime object. it also checks if a link you clicked belongs to a class if so it takes the href value and sends it to the WMP or quicktime objects src and filename values.
the problem is I think getting the file name part to use the detection function.
here is the code.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
/*if you have windows media player*/
function WMPFrame() {
var iframe = document.createElement("iframe");
iframe.setAttribute("src", "WMPIframe.html");
iframe.setAttribute("id", "playerframe");
iframe.setAttribute("scrolling", "no");
iframe.setAttribute("frameBorder", "0");
iframe.setAttribute( "width", "200" );
iframe.setAttribute( "height", "200" );
document.body.appendChild(iframe);
}
/*if you have quicktime*/
function QUIFrame() {
var Frame = document.createElement("iframe");
Frame.setAttribute("src", "QuicktimeIfram.html");
Frame.setAttribute("id", "timeframe");
Frame.setAttribute("scrolling", "no");
Frame.setAttribute("frameBorder", "0");
Frame.setAttribute( "width", "200" );
Frame.setAttribute( "height", "200" );
document.body.appendChild(Frame);
}
/*if you have no plugins*/
function read(){
var answer = confirm ("Please click on OK to continue loading my page,
or CANCEL to be directed to the Yahoo site.")
if (answer)
var MKDIV = document.createElement( 'div' );
MKDIV.setAttribute('id','pluginsite');
MKDIV.style.backgroundColor="#F0CCF0";
MKDIV.style.border = '1px solid blue';
MKDIV.style.left = '35%'
MKDIV.style.top = '200px'
MKDIV.style.width = '300px'
MKDIV.style.heigh = '200px'
MKDIV.style.font = '14px arial #FF6666'
MKDIV.style.position='absolute'
document.getElementsByTagName( 'body' )[0].appendChild( MKDIV );
MKDIV.appendChild(document.createTextNode("To download quick time \u00a0 "))
var lQT=document.createElement('a');
lQT.setAttribute('href','http://www.apple.com/qtactivex/qtplugin.cab' );
lQT.appendChild( document.createTextNode( 'QuickTime' ) );
MKDIV.appendChild(lQT);
MKDIV.appendChild(document.createTextNode("\u00a0 or go to windows media player's download page \u00a0"));
var lWMP=document.createElement('a');
lWMP.setAttribute('href','http://www.microsoft.com/windows/windowsmedia/
download/AllDownloads.aspx' );
lWMP.appendChild( document.createTextNode( 'WMP' ) );
MKDIV.appendChild(lWMP);
window.setTimeout("stopdiv();", 12000)
}
function stopdiv ( )
{
document.body.removeChild(document.getElementById( 'pluginsite'))
}
/*end of no plugin and Iframes.*/
</script>
<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>
<script type="text/javascript">
</script>
<a class="linksclass2" href="#">click</a>
<a class="linksclass2" href="http://www.fileden.com/files/2006/11/20/398972/
lupe%20fiasco%20-%20kick%20push.mp3" return="false">clickhere </a>
<script type="text/javascript">
$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()}
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 (window.event) window.event.returnValue = false; else e.preventDefault();
if(el)
alert(el.innerHTML);
return false;
}
action.linksclass2=function(){
document.getElementById("misterioProgram").style.display="block";
if(detectPlugin( 'QuickTime' ) == true ){
frames['timeframe'].document.getElementsByTagName('embed')[0].src = this.href;
frames['timeframe'].document.getElementsByTagName('param')[0].value = this.href;}
else if (detectPlugin( 'Windows Media Player' ) == true ){
frames['playerframe'].document.getElementsByTagName('embed')[0].src = this.href;
frames['playerframe'].document.getElementsByTagName('param')[0].value = this.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>
<div id="misterioProgram">
<h1 id="vidh">the video page</h1>
<p id="vidp">it will take some time to load</p>
<div id="MTVplayer">
</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>
quicktime iframe
<body>
quicktime Iframe
<OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'
width='320' height='240' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>
<param name='src' value=''>
<param name='autoplay' value='true'>
<param name='controller' value='true'>
<param name='loop' value='false'>
<EMBED src='' width='320' height='240' autoplay='true'
controller='true' loop='false' bgcolor='#000000' pluginspage='http://www.apple.com/quicktime/download/'>
</EMBED>
</OBJECT>
</body>