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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making compatible with Mozilla 2

Status
Not open for further replies.

Delameko

Programmer
Oct 14, 2003
37
GB
How do I go about making a Mozilla-compatible version of this? Thanks.

Code:
            var mypop;
            var str;
            
            function verify()
				{
  					if (xml.readyState != 4)
  					{
      				return false;
  					}
				}

            
            var xml = new ActiveXObject("Msxml2.DOMDocument.3.0");
            xml.async = false;
            xml.onreadystatechange=verify;
            xml.load("[URL unfurl="true"]http://content.thisis.co.uk/mid/general/cinema_listings/Cinema.xml");[/URL]

            function showCinema(venueID)
            {
			    var xsl = new ActiveXObject("MSXML2.FreeThreadedDOMDocument");
			    xsl.async = false;
   				xsl.load("[URL unfurl="true"]http://content.thisis.co.uk/mid/general/cinema_listings/Cinema.xsl");[/URL]
			    var temp = new ActiveXObject("MSXML2.XSLTemplate");
    			temp.stylesheet = xsl;
    			var proc = temp.createProcessor();
    			proc.addParameter("venueID", venueID);
    			proc.input = xml;
    			proc.transform();
    			str = proc.output;
    			mypop=window.open('CinemaPopup.html','newwin','scrollbars=yes,menubar=no,height=600,width=450,resizable=no,toolbar=no,location=no,status=no');
			}
 
You will need to isolate the lines where you access an activeX object and either branch the access (for IE and for Moz). I can see three immediate lines that instantiate ActiveX objects... looking into the alternatives for these would be a good start.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
I can give you a sketch for moz. I do not integrate verify(). It does not serve good purpose.
[tt]
var mypop;
var str;

var xml = document.implementation.createDocument("","",null);
xml.async = false;
xml.load("
function showCinema_moz(venueID)
{
var xsl = document.implementation.createDocument("","",null);
xsl.async = false;
xsl.load(" var temp = new XSLTProcessor();
temp.importStyleshee(xsl);
temp.addParameter("","venueID", venueID);
var xml_t=temp.transformToDocument(xml);
str=new Serializer().serializeToString(xml_t);
mypop=window.open('','newwin','scrollbars=yes,menubar=no,height=600, width=450,resizable=no,toolbar=no,location=no,status=no');
with (mypop) {
document.open();
document.write (str);
document.close();
}
}
[/tt]
You see, I change thing a bit because I don't know why suddenly comes CinemaPopup.html (even in ie version). In any case that's how thing would be done.

ps Could you make some space in the features so that line got wrapped around? That's really annoying the horizontal scrolling. Simply cannot work with mind straight.
 
A typo here. It should be read accordingly.
[tt]temp.importStyleshee[red]t[/red](xsl);[/tt]
 
Thanks a lot, Tsuji, thats great.

The reason for the CinemaPopup.html was because we were having a timing issue, so we had to impliment a callback function (which I only just realised I forgot to post).

Code:
            function myCallBackFunc()
            {
				return str;
			}

and in CinemaPopup.html
Code:
<html>
<head>
<script language="javascript">
function getContent()
{
	var str1;
	str1 = window.opener.myCallBackFunc();
	var oVDiv = document.getElementById("oDiv1");
	oVDiv.innerHTML = str1;
}            
</script>
</head>

<body onload="getContent();">

<div id=oDiv1>
</div>

</body>
</html>
 
Amendment
I'd edited one place for the addparameter line and forgotten to do at the other place. It is this.
>[tt] temp.addParameter("","venueID", venueID);[/tt]
It should be further change to this.
[tt] temp.[red]set[/red]Parameter("","venueID", venueID);[/tt]
 
I seem to have a problem. I've spent most of the day searchin the net for what I thought might be a simple problem. I get the following error in FF console - showCinema_moz is not defined.

After I did some some testing I found it was the use of the function in the html that was the problem. I've had a good look around but I can't find anything on it. What do I need to update with the following code for it work with Mozilla:

Code:
<form name="select">

<select name="cineS" id="cineSelect" length="100%" onchange="showCinema_moz(this.form.cineS.options[this.form.cineS.selectedIndex].value);" style="width:138px; font-size:11px">

<option selected="selected" value="null">Choose your cinema:</option>
<option name="CineName" value="code1">Some cinema</option>
<option name="CineName" value="code2">Another cinema</option>
</select>

</form>

Thanks!
 
The call as such should work. But can simplified a lot to this.
[tt]
<select name="cineS" id="cineSelect" length="100%" onchange="showCinema_moz(this.value);" style="width:138px; font-size:11px">
[/tt]
It is the function itself and integration with global variable etc. Cut down by commenting out some functionality/script lines inside the function and re-insert them progressively.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top