4 Replies - 1032 Views - Last Post: 20 July 2007 - 09:57 AM

#1 quim  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 182
  • Joined: 11-December 05

Javascript and XML browser problem

Posted 19 July 2007 - 11:12 PM

i am building this website for my friend. know i am doing a picture gallery using xml and javascript.
the problem is that in IE i cannot view photos.

here is the site:
[EDITED]
do you have any idea how i may make it work in IE

if you use Firefox it will work just how i expect it

This post has been edited by quim: 21 July 2007 - 08:42 PM

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript and XML browser problem

#2 Arbitrator  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 51
  • View blog
  • Posts: 530
  • Joined: 26-January 05

Re: Javascript and XML browser problem

Posted 19 July 2007 - 11:49 PM

I would start by fixing your errors.
  • xml, imageRoot, and image are not valid under an XHTML DTD nor are those elements members of the XHTML namespace. Ditto for the attributes description, thumbpath, and path.
  • XHTML ID attributes must not begin with a number.
  • Embedded XHTML scripts should be placed within a marked CDATA section if they contain the literal characters < or &.
    <script type="application/ecmascript">
    	//<![CDATA[
    	/* Script Here */
    	//]]>
    </script>
    
    Alternatively, the script can be placed within a separate file.
  • It is incorrect to use document.write in any XHTML document since document.write is incompatible with XML. Use DOM methods instead.

I donít know why youíre claiming to use XML. Viewing that page in Firefox, I can tell that itís being served using a media type of text/html.
Was This Post Helpful? 0
  • +
  • -

#3 quim  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 182
  • Joined: 11-December 05

Re: Javascript and XML browser problem

Posted 20 July 2007 - 12:39 AM

thanks for you help and comment. i will fix everything as you said

Quote

I don’t know why you’re claiming to use XML. Viewing that page in Firefox, I can tell that it’s being served using a media type of text/html.


i said, that is xml than ??
because i learned xml from a video lesson from lynda.com
<xml>,</xml> only works for IE (data island) but still in XML DOM he used that tag and other none tags.
still his code worked in both browser even dough he linked to de XHTML DTD file.

here is the screenshot:
screenshot

This post has been edited by quim: 20 July 2007 - 12:40 AM

Was This Post Helpful? 0
  • +
  • -

#4 Arbitrator  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 51
  • View blog
  • Posts: 530
  • Joined: 26-January 05

Re: Javascript and XML browser problem

Posted 20 July 2007 - 04:40 AM

View Postquim, on 20 Jul, 2007 - 02:39 AM, said:

i said, that is xml than ??
because i learned xml from a video lesson from lynda.com
That document is not being served as XML. To do that, you need to serve it with an XML media type such as application/xml. The XHTML (XML) media type is application/xhtml+xml. The easiest way to change the media type is to change the file extension to *.xml (XML) or *.xhtml or *.xht (XHTML).

You will quickly find that (A) the document will fail to display with a fatal error if there are any well‐formedness errors, (B) document.write fails to work, and © that Internet Explorer doesn’t support real XHTML (XHTML as XML).


View Postquim, on 20 Jul, 2007 - 02:39 AM, said:

<xml>,</xml> only works for IE (data island) but still in XML DOM he used that tag and other none tags.
still his code worked in both browser even dough he linked to de XHTML DTD file.

here is the screenshot:
screenshot
The code in that screen shot is either wrong or Microsoft has decided to mangle the language with their proprietary technologies. The only way to make it correct would be to (A) serve the document as XML, (B) remove the document type declaration, © bind all of the XHTML elements and attributes to a namespace prefix. In that case, it won’t work in Internet Explorer since it doesn’t support real XHTML.

Since you’re embedding the data in the document anyway, you may as well create a Javascript/ECMAScript array and reference that. A basic example is shown below.

var images = [
	["Meninas dancando", "not a good description", "img_049.jpg", "img_049.png"],
	["", "", "img_050.jpg", "img_050.png"],
	["", "", "img_051.jpg", "img_051.png"],
	["", "", "img_052.jpg", "img_052.png"],
	["", "", "img_053.jpg", "img_053.png"],
	["", "", "img_054.jpg", "img_054.png"],
	["", "", "img_055.jpg", "img_055.png"],
	["", "", "img_056.jpg", "img_056.png"],
	["", "", "img_057.jpg", "img_057.png"]
];
function gallery(index) {
	document.getElementById("f_title").firstChild.data = images[index][0];
	document.getElementById("f_descr").firstChild.data = images[index][1];
	document.getElementById("f_thumb").setAttribute("src", "images/thumbnails/" + images[index][2]);
	document.getElementById("f_foto").setAttribute("src", "images/full/" + images[index][3]);
}
for (var i = 0; i < images.length; i++) {
	var image = document.createElement("img");
	image.setAttribute("alt", "thumb");
	image.setAttribute("src", "images/thumbnails/" + images[i][2]);
	if (document.implementation.hasFeature("MouseEvents", "2.0")) {
		image.addEventListener("click", (function (i) { // W3C DOM
			return function () {
				gallery(i);
			};
		})(i), false);
	}
	else if (image.attachEvent) { // Microsoft
		image.attachEvent("onclick", (function (i) {
			return function () {
				gallery(i);
			};
		})(i));
	}
	document.getElementById("all_thumb").appendChild(image); // Use an ID instead of a class.
}

This post has been edited by Arbitrator: 20 July 2007 - 04:41 AM

Was This Post Helpful? 0
  • +
  • -

#5 quim  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 18
  • View blog
  • Posts: 182
  • Joined: 11-December 05

Re: Javascript and XML browser problem

Posted 20 July 2007 - 09:57 AM

thanks again. i guess i will have do them all in .xml and then use loadXMLDoc() and Dom to display them in xhtml (webpage).
i really don't want to use scripting too much or scare off my friends.
they don't even know html so i to make it as easy as i can for them to edit

This post has been edited by quim: 20 July 2007 - 09:58 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1