multiple Onload functions not working in Chrome and Safari - javascript

Here is my code
<body scroll="yes" onload="checkWhileOnload(#{Bean.conLimit},'#{Bean.URL}');checkLoadStatus();hideLoader();">
The problem i m facing is the function checkLoadStatus() is not at all invoked in Safari and Chrome where as it is working fine in IE and FF. can some one please help me on this?

Try separating your js code from your html.
window.onload = function(){
checkWhileOnload(#{Bean.conLimit},'#{Bean.URL}');
checkLoadStatus();
hideLoader();
}
I'm not sure about your quotes, you should look into that

You might want to add a quotes
window.onload = function(){
checkWhileOnload('#{Bean.conLimit}','#{Bean.URL}');
checkLoadStatus();
hideLoader();
}
What does the javascript console console say (Ctrl+Shift+J)

Its just a place problem see this:,
window.onload = function(){
checkLoadStatus();
checkWhileOnload('#{Bean.conLimit}','#{Bean.URL}');
hideLoader();
}
Place your checkload status first; can u do that.:(

Related

Use JQuery or onbeforeunload for IE and FF

I'm working in a Flex4 application, using javascript, in the "index.template.html" document. I'm having an issue being able to use onbeforeunload with Firefox. The application works perfectly in IE, but the exact same one doesn't sit well with FF. (See below)
<script type="text/javascript">
window.onbeforeunload=before;
window.onunload=after;
function before(evt)
{
var flex=document.$(application)||window.$(application);
flex.unloadMethod(); //custom method to log out the user
}
function after(evt)
{
}
</script>
From what I've found, FF doesn't seem to register onbeforeunload events, so I found that the popular thing to use instead is binding with JQuery. So, I deleted the above code and replaced it with the below code, but it doesn't display a pop-up when the user tries leaving the page in both IE and FF. Anyone that seems to be using JQuery for this seems to be doing the exact same thing, so I don't know what's going on.
<script type="text/javascript">
$(window).bind("beforeunload",function(event){
return "This should create a pop-up";
});
</script>
Eventually it would be nice to call the "flex.unloadMethod" like in the first bit of code, but for the time being I'm just trying to get a pop-up to work so I know I'm on the right track. Any insight would be greatly appreciated.
Try:
<script>
$(window).on('beforeunload', function(){
return "This should create a pop-up";
});
</script>
Example: http://jsfiddle.net/AeztA/3/
Would like to add that i figured out that you can't use an empty string in firefox.
It has to be at least 1 blank for example as return.
var text = 'Exit Message';
$(window).on('beforeunload', function(){
return " " + text;
});

IE 7/8 Javascript issue

Hi i hope you can help me
I am having an issue in IE 7/8 with the rock solid template. See the template http://www.pixelsparadise.com/showcase_2013/#load=http://www.rocksolid.joomlatemplates.info
It seems to be caused by JavaScript code in the header.
The error code i receive in the IE debugger is
SCRIPT1014: Invalid character
<script type="text/javascript">document.getElementById("sectors").addEventListener('change', function () {
window.location = this.value;},false); ​</script>
This is the piece of code seemingly causing the problem.
Basically the area stops any button used within the template from working. Any ideas how to fix this for Internet Explorer 7/8?
Thanks
You have an extra, "invisible" (it can be seen if you copy that code into something like Notepad++) character just before the </script> tag; just delete everything between the ; and </script> and it should be resolved.
take out the space in the script tag closure
​</script>
change to
<script type="text/javascript">document.getElementById("sectors").addEventListener('change', function () {
window.location = this.value;},false); </script>

document.body.onload in Firefox

Okay so I'm using Javascript to set the onload attribute of a page. It works in IE but not Firefox. Does anyone know a fix for this? Neither IE or Firefox is throwing an error. I'm using the Firefox plugin "Web Developer" and it isn't showing any JavaScript errors. Code below: Thanks.
document.body.onload = setRedirect;
function setRedirect()
{
alert("TEST");
}
Change to:
window.onload = setRedirect;
Also see this jsfiddle.

add click function with jQuery not work

the js code is here
var s = "<a id='clickmodifybasic'>修改</a>"
$("#basicinfoerrordlg").html(s);
$("#clickmodifybasic").click(modifybasicinfo);
$("#basicinfoerrordlg").dialog("open");
return false;
it work well on chrome,but not good in IE8.
I got similar error before.
I get the following code from the develop tool of IE8.
<A id=clickmodifybasic jQuery1289741833331="94">修改</A>
Assuming that you have a modifyBasicinfo() function already defined, try this code.
var s = "<a id='clickmodifybasic'>修改</a>";
$("#basicinfoerrordlg").html(s);
$("#clickmodifybasic").click(function() { modifybasicinfo(); });
$("#basicinfoerrordlg").dialog("open");
return false;
Don't forget your ";" delimiter after you variable declaration, I have added this in for you.
Hope this helps.
#WangXing, I have just tested in IE8 with this exact code:
<script type="text/javascript">
function ModifyBasicInfo()
{
alert("clicked");
}
$(function() {
var s = "<a id='clickmodifybasic'>קישור</a>"
$("#basicinfoerrordlg").html(s);
$("#clickmodifybasic").click(ModifyBasicInfo);
});
</script>
<div id="basicinfoerrordlg"></div>
It worked fine, and alert appeared when clicking the link so the problem must be with the dialog plugin you're using. What plugin is this exactly? Can you post link so we can reproduce this behavior?

jQuery $ is not a function in Firefox, works in Chrome and works with $(document).ready()

I'm implementing jQuery in a site and am getting the "$ is not a function" in Firefox when I try to use a selector, but $(document).ready() works perfectly right before it. My code looks like this
<script>
$(document).ready(function(){
alert("hi")
}); // Works fine
function showDiv(){
$("#traditionalCC").hide();
}
//Throws error
</script>
Does anyone know why this happens, and why it works in Chrome and Firefox.
The key difference between your two examples (the working and non working ones) is that the first one is using the document ready event. That happens when the page is fully loaded. Not sure when you're other one is getting invoked, but my guess is that it is being called before your <script> tag include for jquery.js itself.
Try
<script>
$(function() {
alert("hi")
}); // Works fine
function showDiv(){
$("#traditionalCC").hide();
}
//Throws error
</script>
Try to use
$(document).ready(function() {
$ = jQuery.noConflict();
});
Fix your script declaration to <script type="text/javascript">
Verify if your script is after the jQuery lib include.
I hope it help.
I have found that sometimes Firefox gets "hosed" and I have to quit and relaunch.
In case anyone comes across this in the future, the problem was FireBug. I uninstalled and reinstalled and the issue went away.

Categories