TESTING: Removed. Wrath of feyd was expected...
Function Within A Function
Moderator: General Moderators
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
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...
TESTING: Removed. Wrath of feyd was expected...
Last edited by n00b Saibot on Mon Apr 24, 2006 12:27 pm, edited 4 times in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
<QuickComment please="don't respond">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...
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>OK, so this piece of code here gives me an 'unknown runtime error'
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.
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>Ideally I want the <p>Hurray! It works!</p> to be a hidden div with the link to the image inside of it.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
for the sake of testing, I also put that display:none nut that also fails to reproduce error on my test page.
do you have more code than you're showing
maybe something in that part is messing it up... can you show me that code???
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>
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.
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:
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?
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;">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 #3: Does it matter if this script is in the head of the document? Does it matter if I use the <!-- //--> comment lines?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Rule #1: Put JS code in the <head> where possible except where rule #2 gets in the wayscottayy wrote:Does it matter if this script is in the head of the document? Does it matter if I use the <!-- //--> comment lines?
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).