Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change from targeting a frame in a frameset to an inline frame..

Status
Not open for further replies.

mechman2

Technical User
Jul 31, 2007
2
US
Hi Everyone:

I have very limited Javascript knowledge. We are trying to switch a page from a frameset (x2 frames) to a regular .html page with an inline frame. The javascript is in the main content area. It writes links to the side column frameset. My boss wants to do away with the frames and have the javascript write to the inline frame. Here is the code that I think applies (in yellow):

Code:
// Simple error check to make sure that there are markers in the file.
    if (iNumMarkers != -1) {
	// "For" loop which creates all of the inline JavaScript anchor tags
	for (var i = 1; i <= iNumMarkers; i++) {
		sTempString = sTempString + "<A HREF=\"javascript:parent.frames[1].seekToMarker(";
		sTempString = sTempString + i + ")\">";
		sTempString = sTempString + document.MediaPlayer1.GetMarkerName(i);
		sTempString = sTempString + "</A><BR>"
	}
	// Actual code which writes the information to the other frame.
	parent.frames[0].document.open();
	parent.frames[0].document.writeln("<HTML><BODY BGCOLOR=\"#ffffff\">");
	parent.frames[0].document.writeln(sTempString);
	parent.frames[0].document.writeln("</BODY></HTML>");
	parent.frames[0].document.close();

    } else {
	
	alert("There are no Markers in this file");
    }
}
I don't know how to change the "parent.frames[0].document.writeIn to write in the inline frame. The inline frame's actual page name is: menu.html and the id of the inline frame is: menumarker. The inline frame is located in a page called: player.html

Thanks for any help... I need it!
Bill
 
Followup...

Edit: More information:
The Javascript in the main frame is extracting the data from a separate file. The data is converted to links and placed in the second frame in the frameset automatically. (The links are so that viewers can click and be taken to specific topics/parts of the media player file. Thanks again.Bill

Here is more code:
Code:
<SCRIPT LANGUAGE = "JavaScript"  FOR = MediaPlayer1 EVENT = playStateChange(NewState)>

// Test for the player current state, display a message for each.
switch (NewState){
	case 2:
		//alert("paused");
		break;

	case 3:
		//alert("playing");
		loader();
		break;

   case 10:
	   alert("Ready");
     break;

    // Other cases go here.

    default:
        ;
}
</SCRIPT>

<BODY BGCOLOR="#ffffff" onLoad="loader()">
<CENTER>
<!--     <SCRIPT type="text/javascript">
      if(-1 != navigator.userAgent.indexOf("MSIE"))
      {

        document.write('<OBJECT id="MediaPlayer1"');
        document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
        document.write(' width=300 height=200>');
        document.writeln('<PARAM NAME="FileName" VALUE="CCR_IRM_LM-031506.wmv?sami=[URL unfurl="true"]http://10.3.196.31/wmpindex/CCR_IRM_LM-031506.smi">');[/URL]
        document.writeln('</OBJECT>')
      }
      else if(-1 != navigator.userAgent.indexOf("Firefox"))
      {
      	alert("FireFox");
        document.write('<OBJECT id="MediaPlayer1"');
        document.write(' type="application/x-ms-wmp"');
        document.write(' width=300 height=200></OBJECT>');
      }
    </SCRIPT>-->

<!--BEGIN GENERIC ALL BROWSER FRIENDLY HTML FOR WINDOWS MEDIA PLAYER-->
<OBJECT ID="MediaPlayer1" height="594" width="704"
	classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
	codebase="[URL unfurl="true"]http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"[/URL]
        standby="Loading Microsoft? Windows? Media Player components..."
        type="application/x-oleobject">
  <PARAM NAME="FileName" VALUE="CCR_IRM_LM-031506.wmv?sami=[URL unfurl="true"]http://10.3.196.31/wmpindex/CCR_IRM_LM-031506.smi">[/URL]
  <PARAM NAME="ShowStatusBar" VALUE="True">
	<param name = "CaptioningID" value = "CapText1">
	<EMBED
		SRC="CCR_IRM_LM-031506.wmv"
		width=704
		height=594 type="application/x-mplayer2"
		pluginspage = "[URL unfurl="true"]http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/"[/URL]
		ShowStatusBar=True filename="CCR_IRM_LM-031506.wmv?sami=[URL unfurl="true"]http://10.3.196.31/wmpindex/CCR_IRM_LM-031506.smi"[/URL] captioningid="CapText1">	</EMBED>
</OBJECT>
<!-- END GENERIC ALL BROWSER FRIENDLY HTML FOR WINDOWS MEDIA PLAYER -->
<DIV name ="CapText1" id = "CapText1">hello</DIV>



<!-- <input type="button" name="button1" value="load" onClick="loader()"> -->



<SCRIPT Type="Text/JavaScript">

// This function (called on the onload event of the window) will query the
//	Media Player for the number of markers and create the Toc from that data.
function loader(){
    var iNumMarkers;
    var sTempString = "";

		//if (document.MediaPlayer1.playState == 3){
			//alert("ready");
		//}

    // Simple browser sniff
    if (navigator.userAgent.indexOf("MSIE") != -1) {
	     iNumMarkers = document.MediaPlayer1.MarkerCount;
    } else {
	     iNumMarkers = document.MediaPlayer1.GetMarkerCount();
    }

    // Simple error check to make sure that there are markers in the file.
    if (iNumMarkers != -1) {
	// "For" loop which creates all of the inline JavaScript anchor tags
	for (var i = 1; i <= iNumMarkers; i++) {
		sTempString = sTempString + "<A HREF=\"javascript:parent.frames[1].seekToMarker(";
		sTempString = sTempString + i + ")\">";
		sTempString = sTempString + document.MediaPlayer1.GetMarkerName(i);
		sTempString = sTempString + "</A><BR>"
	}
	// Actual code which writes the information to the other frame.
	parent.frames[0].document.open();
	parent.frames[0].document.writeln("<HTML><BODY BGCOLOR=\"#ffffff\">");
	parent.frames[0].document.writeln(sTempString);
	parent.frames[0].document.writeln("</BODY></HTML>");
	parent.frames[0].document.close();

    } else {
	
	alert("There are no Markers in this file");
    }
}


// This function receives an integer from the buttons on the other page and resets the //      current position of the file to that marker.
function seekToMarker(iWhichMarker){
    if (navigator.userAgent.indexOf("MSIE") != -1) {
	// This is an error handler.  If the user tries to scan to a marker which doesn't
	//     exist, the player will pop an error message.  By using this code, we
	//     can create a custom error message.
	if (iWhichMarker <= document.MediaPlayer1.MarkerCount) {
		// This resets the current marker in the file.
		document.MediaPlayer1.CurrentMarker = iWhichMarker;
	} else {
		alert("This Marker doesn't exist.");
	}
    } else {
	if (iWhichMarker <= document.MediaPlayer1.GetMarkerCount()) {
		document.MediaPlayer1.SetCurrentMarker(iWhichMarker);
	} else {
		alert("This Marker doesn't exist.");
	}

    }
}
</SCRIPT>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top