Jump to content

window.open problem


rondog

Recommended Posts

I have a popup at the end of a quiz. It works fine in IE, but I get a debug error in IE7 and it points to this line in my js:

 

Also, the error is 'Invalid Argument'.

<?php
var surveyTaken;
var newWindow;

function window_onunload() {
if(SCORM.connection.isActive){
	if(SCORM.data.get("cmi.core.lesson_status") == "passed" || SCORM.data.get("cmi.core.lesson_status") == "completed" )
	{
		//launch the survey if its false
		if(surveyTaken == false)
		{
			newWindow = window.open("survey.htm","Course Evaluation"); //This line!
			if(window.focus)
			{
				newWindow.focus();
			};
		}
	}
	SCORM.connection.terminate();
}
}
?>

 

Any idea whats going on?

Link to comment
https://forums.phpfreaks.com/topic/121489-windowopen-problem/
Share on other sites

ok you were right, the window title was throwing it off. I have another question now...

 

The man wants me to use this code since were using an iframe:

<?php
		if(typeof parent != "undefined")
		{
			parent.document.location.href = "survey.htm";
		}
		else
		{
			document.location.href = "survery.htm";
		}
?>

 

That isnt working at the moment and I am not familiar with iframes

Link to comment
https://forums.phpfreaks.com/topic/121489-windowopen-problem/#findComment-627044
Share on other sites

Uh, first of all, that's NOT php code. Remove the PHP tags.

 

Also, you should give the iframe a name attribute. Something like:

<iframe name='theframe' id='theframe'></iframe>

 

Then use this JavaScript code:

var tehFrame = null;
if (document.all) tehFrame = frames['theframe'];
else tehFrame = document.getElementById("theframe");

if (tehFrame !== null) tehFrame.src = "survey.htm";
else window.location.href = "survey.htm";

Link to comment
https://forums.phpfreaks.com/topic/121489-windowopen-problem/#findComment-627096
Share on other sites

I know its not PHP, but using the PHP tags, you get somewhat accurate color tagging and its easier to read then the code tags.

 

Ok so I tried your method and still no luck. Here is my whole function:

<?php
function window_onunload() {
if(SCORM.connection.isActive){
	if(SCORM.data.get("cmi.core.lesson_status") == "passed" || SCORM.data.get("cmi.core.lesson_status") == "completed" )
	{
		var theFrame = null;
		if(document.all)
		{
			theFrame = frames['lmscontentFrame'];
		}
		else
		{
			theFrame = document.getElementById("lmscontentFrame");
		}

		if(theFrame !== null)
		{
			theFrame.src = "survey.htm";
		}
		else
		{
			window.location.href = "survey.htm";
		}			
	}
	SCORM.connection.terminate();
}
}
?>

 

It is in an onunload function so I think this defeats the iframe thing anyway. I just need to popopen a survey when the user closes the course window. The way I was doing it before was working, but they suggest I do it this way...I have no idea why...

Link to comment
https://forums.phpfreaks.com/topic/121489-windowopen-problem/#findComment-627148
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.