Page 2 of 2

Posted: Mon Apr 24, 2006 12:22 pm
by n00b Saibot
so what's the difference if i post them in syntax or outside it. the threat will be same... isn't it? after all, syntax block is just same plain html after all :?

TESTING: Removed. Wrath of feyd was expected... :lol:

Posted: Mon Apr 24, 2006 12:23 pm
by feyd
You don't need to post your tests, so get back on topic.

Posted: Mon Apr 24, 2006 4:43 pm
by Chris Corbyn
n00b Saibot wrote:so what's the difference if i post them in syntax or outside it. the threat will be same... isn't it? after all, syntax block is just same plain html after all :?

TESTING: Removed. Wrath of feyd was expected... :lol:
<QuickComment please="don't respond">

It's actually a problem with the mod that makes use of Geshi. The author of the mod claims it be unavoidable but there are apparently ways around it (ala

Code: Select all

).

</QuickComment>

Posted: Mon Apr 24, 2006 8:45 pm
by s.dot
OK, so this piece of code here gives me an 'unknown runtime error'

Code: Select all

<script type="text/javascript">
<!--
function showPicDetails(pic,who,id){
		document.getElementById('picView').innerHTML = '<img src="../../uploads/'+who+'/'+pic+'" alt="Photo"><br><br><a href="javascript: void(0);" onClick="alert('+id+');">Get Link</a><p>Hurray! It works!</p>';
}
//-->
</script>
Whereas the same piece of code without the <p>Hurray! It works!</p> on it works.

Ideally I want the <p>Hurray! It works!</p> to be a hidden div with the link to the image inside of it.

Posted: Mon Apr 24, 2006 11:17 pm
by feyd
It's hard to say what could be wrong at this point, so all I can recommend is using the DOM to build this content instead of using innerHTML.

Posted: Tue Apr 25, 2006 11:41 am
by n00b Saibot
for the sake of testing, I also put that display:none nut that also fails to reproduce error on my test page.

Code: Select all

<script type="text/javascript">
<!--
function showPicDetails(pic,who,id){
 document.getElementById('picView').innerHTML = '<img src="../../uploads/'+who+'/'+pic+'" alt="Photo"><br><br><a href="javascript: void(0);" onClick="alert('+id+'); document.getElementById('+id+').style.display=\'\';">Get Link</a><p id='+id+' style="display:none">Hurray! It Runs!</p>';
}
//-->
</script>
<a href="javascript:showPicDetails('x', 'y', '1')">Click here</a><br />
<div id="picView"></div>
do you have more code than you're showing :?: maybe something in that part is messing it up... can you show me that code???

Posted: Tue Apr 25, 2006 2:00 pm
by s.dot
The page is about 300 lines of code, so there could be a lot of potential for something that's messing it up.

This is the function I have, and the way I am calling it.

Code: Select all

<script type="text/javascript">
<!--
function showPicDetails(pic,who,id){
	document.getElementById('picView').innerHTML = '<img src="../../uploads/'+who+'/'+pic+'" alt="Photo"><br><br><a href="javascript: void(0);" onClick="alert('+id+');">Get Link</a><p>Hurray! It works!</p>';
}
//-->
</script>

Code: Select all

<img src="thumbs/<?php echo $album_array['userid']; ?>/<?php echo $pica['img']; ?>" alt="Photo Album Picture" onClick="showPicDetails('<?php echo $pica['img']; ?>','<?php echo $album_array['userid']; ?>','<?php echo $pica['id']; ?>');" style="cursor: hand;">
Unless the error is in those lines of code somewhere, I'll have to go digging through the rest of it.

Edit: When that php code is evaluated, the result looks like this:

Code: Select all

<img src="thumbs/1/1145928974da8d48d3db.jpg" alt="Photo Album Picture" onClick="showPicDetails('1145928974da8d48d3db.jpg','1','74');" style="cursor: hand;">
Edit #2: Unfortunately, when I isolate my code... it works. =] So, bleh.. onto looking at the rest of the script.
Edit #3: Does it matter if this script is in the head of the document? Does it matter if I use the <!-- //--> comment lines?

Posted: Tue Apr 25, 2006 5:37 pm
by Chris Corbyn
scottayy wrote:Does it matter if this script is in the head of the document? Does it matter if I use the <!-- //--> comment lines?
Rule #1: Put JS code in the <head> where possible except where rule #2 gets in the way
Rule #2: JS code in the head that calls any of the DOM methods/properties will likely fail if it executes inline with page loading... code stored in the head relating to DOM should only be executed once the page is fully loaded (since the "document" object isn't ready otherwise).

Posted: Tue Apr 25, 2006 9:54 pm
by Benjamin
Any reason why you can't just call the nested function from within the main function and seperate the two?