•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 373,936 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,775 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2016 | Replies: 8
![]() |
•
•
Join Date: Dec 2006
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
Hi,
I got very very strange problem. Since 19 of december, when all FireFox in company was upgrated automaticaly, code below stopped working. Strange thing is, when i wanted to solve it, it started to work when i've putted alert() function. Here you have working and not working examples. I'll add that this function is used about 4 times on the site:
NOT WORKING SCRIPT:
WORKING SCRIPT:
When press "ok" in alert popup, it works, without alert....crap...
Any ideas whats wrong?
I got very very strange problem. Since 19 of december, when all FireFox in company was upgrated automaticaly, code below stopped working. Strange thing is, when i wanted to solve it, it started to work when i've putted alert() function. Here you have working and not working examples. I'll add that this function is used about 4 times on the site:
NOT WORKING SCRIPT:
JavaScript Syntax (Toggle Plain Text)
function loadJSintoDIV(id, url, switchdiv) { obj = document.getElementById(id); if(obj.innerHTML == '' || !switchdiv) { oelem=document.createElement("script"); oelem.src=url; oelem.type="text/javascript"; oelem.defer=true; document.getElementsByTagName("head")[0].appendChild(oelem); obj.style.height = ''; obj.style.visibility = 'visible'; } else { obj.innerHTML = ''; obj.style.height = '0px'; obj.style.visibility = 'hidden'; } }
WORKING SCRIPT:
JavaScript Syntax (Toggle Plain Text)
function loadJSintoDIV(id, url, switchdiv) { obj = document.getElementById(id); alert('test'); if(obj.innerHTML == '' || !switchdiv) { oelem=document.createElement("script"); oelem.src=url; oelem.type="text/javascript"; oelem.defer=true; document.getElementsByTagName("head")[0].appendChild(oelem); obj.style.height = ''; obj.style.visibility = 'visible'; } else { obj.innerHTML = ''; obj.style.height = '0px'; obj.style.visibility = 'hidden'; } }
When press "ok" in alert popup, it works, without alert....crap...

Any ideas whats wrong?
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation:
Rep Power: 5
Solved Threads: 46
Where, or if you prefer when, is this code executed?
To be precise, what event* do you use to execute the function?
I ask that because, (I'll go out on a limb here) the code may be being executed as the page loads, but (perhaps) the script can only function correctly when the page is loaded fully. Forcing you to answer a modal message box {via alert()} causes the execution of the remainder of the function to be temporarily paused, meaning that when the important parts of the function are executed, the page has loaded.
Like I hope that I implied, that's an assumption founded on a working knowledge rather than any practical tests or even directly related experience**. The easiest way to find out if this is the case is to try putting the alert() after the function's main body, and posting back what happens.
Also; do say where the code is called from/when it is called.
*'inside script tags' is a viable event of sorts.
**or infact, a complete understanding of what you're trying to achieve. If you're calling this function from a user invoked event (like a click) on a fully loaded page; I have no idea.
To be precise, what event* do you use to execute the function?
I ask that because, (I'll go out on a limb here) the code may be being executed as the page loads, but (perhaps) the script can only function correctly when the page is loaded fully. Forcing you to answer a modal message box {via alert()} causes the execution of the remainder of the function to be temporarily paused, meaning that when the important parts of the function are executed, the page has loaded.
Like I hope that I implied, that's an assumption founded on a working knowledge rather than any practical tests or even directly related experience**. The easiest way to find out if this is the case is to try putting the alert() after the function's main body, and posting back what happens.
Also; do say where the code is called from/when it is called.
*'inside script tags' is a viable event of sorts.
**or infact, a complete understanding of what you're trying to achieve. If you're calling this function from a user invoked event (like a click) on a fully loaded page; I have no idea.
Last edited by MattEvans : Jan 2nd, 2007 at 2:59 am.
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Dec 2006
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
OK,
First of all, the function is loaded from *.js file.
Then it is called 6 or 7 times on one page by call like this:
Now, first load of page. If the last parameter is true, div is still hidden. If false, div is loaded by appendChild(). Of course, later every part of page can be hidden and loaded by button, but it is working.
The problem is, that while page is loading 3 functions have last parameter false, so 3 parts normally was loaded. After last FF update only first is loaded, and other 2 is not.
Starting to work with alert, as i said...
Any ideas?
First of all, the function is loaded from *.js file.
Then it is called 6 or 7 times on one page by call like this:
JavaScript Syntax (Toggle Plain Text)
loadJSintoDIV('emailsList', 'crm_overview_emails.php?unique=emailsList&thr_id={$thr_id}&kon_id={$kon_id}&List_Eml_ID={$get.List_Eml_ID}', true); //code in {...} is Smarty
The problem is, that while page is loading 3 functions have last parameter false, so 3 parts normally was loaded. After last FF update only first is loaded, and other 2 is not.
Starting to work with alert, as i said...
Any ideas?
Last edited by pojke : Jan 2nd, 2007 at 4:35 am.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation:
Rep Power: 5
Solved Threads: 46
what happens if you try this code:
Notice the movement of the alert() line. This isn't an attempt to solve your problem, but let me know if it has the same effect as having the alert() line first, or if there is a difference
function loadJSintoDIV(id, url, switchdiv) {
obj = document.getElementById(id);
if(obj.innerHTML == '' || !switchdiv) {
oelem=document.createElement("script");
oelem.src=url;
oelem.type="text/javascript";
oelem.defer=true;
document.getElementsByTagName("head")[0].appendChild(oelem);
obj.style.height = '';
obj.style.visibility = 'visible';
} else {
obj.innerHTML = '';
obj.style.height = '0px';
obj.style.visibility = 'hidden';
}
alert('test');
}Notice the movement of the alert() line. This isn't an attempt to solve your problem, but let me know if it has the same effect as having the alert() line first, or if there is a difference
Last edited by MattEvans : Jan 2nd, 2007 at 5:11 am. Reason: ahhh having probs with codetags and pasted code
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation:
Rep Power: 5
Solved Threads: 46
what about the event that calls that function during loading? is it called like this:
or like this:
or by some other means?
<body onload="loadJSintoDIV(etc);"> ...
or like this:
<script type="text/javascript"> loadJSintoDIV(etc); </script>
or by some other means?
If it only works in Internet Explorer; it doesn't work.
•
•
Join Date: Dec 2006
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
The second way :
JavaScript Syntax (Toggle Plain Text)
<script language="JavaScript"> loadJSintoDIV('emailsList', 'crm_overview_emails.php?unique=emailsList&thr_id={$thr_id}&kon_id={$kon_id}&List_Eml_ID={$get.List_Eml_ID}', true); </script>
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 916
Reputation:
Rep Power: 5
Solved Threads: 46
•
•
Join Date: Dec 2006
Posts: 17
Reputation:
Rep Power: 2
Solved Threads: 0
Unfortunately i can't use straight the first way, its because every function call is in another file (p.e. mails in crm_mail.tpl, faxes in crm_fax.tpl, letters in crm_letters.tpl), so i need Smarty variables after <body> which is in _header.tpl (In one page is about 20 files loaded for whole system).
I can try change at the end document.getElementsByTagName("body")[0].onload but it needs reference to a function, so all 3 calls need to be put in one moment, and i'm not sure how long Smarty remember variables. I'll try...
I can try change at the end document.getElementsByTagName("body")[0].onload but it needs reference to a function, so all 3 calls need to be put in one moment, and i'm not sure how long Smarty remember variables. I'll try...
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
- Javascript Problem.... (JavaScript / DHTML / AJAX)
- Javascript problem in FIREFOX (JavaScript / DHTML / AJAX)
- Javascript Problem with Firefox (JavaScript / DHTML / AJAX)
- Page Cannot Be Displayed & javascript:doNetDetect() Errors (Viruses, Spyware and other Nasties)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: [Javascript] My browser/computer doesn't like Javascript...?
- Next Thread: Filling values of a dropdown


Linear Mode