Sign in to follow this  
nvfellers

Charts not displaying in .xhtml pages in Safari

Recommended Posts

If your web pages have a .xhtml extension, following strict HTML 4.01 compliance, then they stop working in browsers that adhere to strict standards (e.g., Safari), when run on an application server. For my situation, the reason the pages have .xhtml extensions is that I am using JavaServer Faces (JSF) with Facelets. Separately, I believe mobile phones and other small devices also render xhtml, but I may be mistaken.

 

 

 

To solve the problem, I modified fusioncharts.js by revising the the render and getSWFHTML functions:

 


render: function(elementId){

                      else {

			//Normal case. Instantly load the chart

			if (navigator.appName.indexOf("Microsoft Internet") != -1) {

				n.innerHTML = this.getSWFHTML();

			}else  {

				var embed = document.createElement('embed');

				this.getSWFHTML(embed);

				n.appendChild(embed);

			}

		}

}

getSWFHTML: function(node) {

	var swfNode = "";

	if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { 

		// netscape plugin architecture			

		node.setAttribute('type', 'application/x-shockwave-flash');

		node.setAttribute('src', this.getAttribute('swf'));

		node.setAttribute('width',  this.getAttribute('width'));				

		node.setAttribute('height', this.getAttribute('height'));

		node.setAttribute('id', this.getAttribute('id'));

		node.setAttribute('name', this.getAttribute('id'));



		var pairs = this.getVariablePairs().join("&");

		var params = this.getParams();

		for(var key in params) { 

			params[key].replace(/&/g, "&").replace(/, "<").replace(/>/g, ">");

			node.setAttribute([key], params[key]); 

		}



		if (pairs.length > 0){

			pairs.replace(/&/g, "&").replace(/, "<").replace(/>/g, ">");

			node.setAttribute('flashvars', pairs); 

		}

             }else

 

Vance

Edited by Guest

Share this post


Link to post
Share on other sites

The root of this problem, when using xhtml, is that the rendered embed tag is not closed, thus not standards compliant. This fact does not bother IE or Firefox, which I assume are rendering in quirks mode; however, browsers like Safari and probably Chrome will not display the embedded charts.

 

 

 

The top of my pages look as follows:

 



!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

html xmlns="http://www.w3.org/1999/xhtml"

xmlns:ui="http://java.sun.com/jsf/facelets"

xmlns:f="http://java.sun.com/jsf/core"

xmlns:h="http://java.sun.com/jsf/html" >

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this