HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

JavaScript Killing Firefox 2+3

06-29-2008, 01:08 AM#1
TheSecretArts
I have these 3 simple scripts written in Javascript that when uncommented cause the page not too load and at the bottom say "Stopped". and when I comment them they work fine.
They are in the body.

Scripts:
The only problem with this script is that is doesn't execute the onlick on command, and IE7 says it is condition compilation variables blah blah...
Code:
document.write('<a onclick="popI('+"'"+"<xsl:value-of select='@uid' />"+"'"+')" >Comments</a>');
The rest work fine in IE7 (and IE8 Beta 1) and Safari.
Code:
document.write("<br />");
a="<xsl:value-of select='body/image/@src' />";
d='"'+a+'"'
b="<xsl:value-of select='body/image' />";
e='"'+b+'"'
c="<img src="+d+" alt="+e+" />";
document.write(c);
Code:
document.write("Link: ");
y="<xsl:value-of select='body/link' />";
x="<a href="+y+" ><xsl:value-of select='body/link' /></a>";
document.write(x);
document.write("<br />");
Code:
var x=0;
var txt='<xsl:value-of select="body/text" />';
document.write(txt);
07-02-2008, 02:54 PM#2
TheSecretArts
Ok, seriously, anyone with experience with JavaScript, I could really use some help.
A cross-browser application doesn't work very well when it doesn't work a major browser.
07-02-2008, 03:42 PM#3
Alevice
You pass popI the "string":
PHP Code:
'<xsl:value-of select='@uid' />' 
Which I presume you meant
PHP Code:
'<xsl:value-of select="@uid" />' 

That is, the single quotes around @uid should be double quotes. May I ask why do you use document.write, anyway? document write, once the browser has finsihed loading the page, will overwrite what is already there, and given your examples, you don't really need it at all (and heck, DOM manipulation is way safer). In addition to the fact that in your second script, you are outputting
PHP Code:
<img src="<xsl:value-of select='' />" alt=<xsl:value-of select='body/image' />" /> 
Where you should be usying the xsl:attribute element, so it would en up more or less like
PHP Code:
<img>
  <
xsl:attribute name="src">
    <
xsl:value-of select="body/image/@src" />
  </
xsl:attribute
  <
xsl:attribute name="alt">
    <
xsl:value-of select="body/image" />
  </
xsl:attribute
</
picture
Also, you could save yourself some concatenation by using escape characters like \".


EDIT: I just read your other thread, and may I ask why are you reinventing the wheel? You could just transform RSS and be done with that. Your definition does not seem to extend/change anything that rss doesn't already do Maybe I am missing something there, so I would like to hear about it :P
07-02-2008, 05:37 PM#4
TheSecretArts
Well, I just don't know why they work fine in IE7/8 and Safari but not Firefox. heck, IE doesnt give anyscript errors.

I have 4 reasons why I want to do this
1. Real-world method of learning and experimenting with XML
2. I find it more convenient for personal use.
3. It looks very similiar on all browsers. While on Safari RSS looks very different.
4. It's a fun challenge for me to create this. I'm a do-it-yourselfer.

What im making is kinda like a blog meets RSS.
07-02-2008, 06:17 PM#5
Alevice
Quote:
Originally Posted by TheSecretArts
Well, I just don't know why they work fine in IE7/8 and Safari but not Firefox. heck, IE doesnt give anyscript errors.

I'd suspect parsing bugs, but I am surprised this happens as well on safari (considering the nature of webkit). Are you using 3.5?

In any case, I'd invit you to use escape characters. Easier to follow. Or better yet, proper xsl :P

Try installing the firebug plugin, btw, it's console give quite a lot of detail for this things. In addition to being an awesome dev tool.


Quote:
Originally Posted by TheSecretArts
I have 4 reasons why I want to do this
1. Real-world method of learning and experimenting with XML
2. I find it more convenient for personal use.
3. It looks very similiar on all browsers. While on Safari RSS looks very different.
4. It's a fun challenge for me to create this. I'm a do-it-yourselfer.

Yeah, I can see what you mean. I still feel tehre are better ways to learn XML, like writing a datasource independant OOP CMS ;P

DOM manipulation helps a lot for understanding XML
07-03-2008, 06:15 PM#6
TheSecretArts
Well I've tested it on a wide plethora browsers (Safari, IE, Firefox, Netscape, Opera, Deepnet) and the only browsers it didnt work on was Firefox and Netscape.

Firebug isnt telling me terrible much either.

I'll probably have to switch to JS XML DOM... Gah.
07-04-2008, 04:43 AM#7
Alevice
If you really want to manipulate xml documents, you are certainly obliged to learn DOM ;P