Here are the problem scripts:
This is from the HTML file:
<script type="text/javascript">
var devices_record = "some string";
</script>
<script type="text/javascript" src="/js/foo.js"></script>
This is from foo.js:
function bar () {
devices_record ...
|
I just spent some time debugging a problem that boiled down to forgetting to use the var keyword in front of a new variable identifier, so Javascript was automatically creating that ... |
Can I do this ?
var global = 0;
var truc = $.getJSON("events.json", function(json){
//alert("JSON Data: " + json[0].titre);
global = json;
});
I want to keep the contents of json and work with ... |
So I'm playing around with JavaScript and came across what I think to be an oddity. Is anyone able to explain the following? (i've included the alerted values as comments)
Why is ... |
beginner here...
what am i missing?
i define a global variable that is a reference to an html element:
var x=document.getElementById("xxx1");
then, inside a function a ... |
my question is actually one of understanding - I have a working solution, I just don't understand how it works.
Okay, so - what I'm trying to do is adding a setTimeout ... |
I am having a strange problem with global variables disappearing on me. Here is some stripped down semi-pseudo-code:
var globy = 99;
jQuery.get("file", function(){
check();
})
function check(){
main();
}
function main(){
forloop
whileloop
...
|
|
I am creating a GM script and had a question about how to set it up with as little global pollution as possible.
I have 1 main function which is available and ... |
I thought any variable defined in a function would be local but I can easily access variable 'e' outside of its function.
function change() {
var d = 6;
e ...
|
I'm new to JS and a bit confused on this subject, I hope you'll understand the question:
When I want to use in one function a variable coming from another,
or coming from ... |
I submitted my addon to the AMO direcotry and the editor came back with this:
There are still a number of variables being leaked to the global scope,
probably because you're using ...
|
How to declare a global variable using JavaScript, whose life remain through out the HTML code?
Can we access the variable that we had declared in one script in another script?
|
Can anyone tell me how i could use a global scope variable so that I could close "window 1" from "window2"?This is really throwing me for a loop, so any help ... |
Here's my code
errors=0;
$(document).ready(function () {
var chk=$("#usnm").val();
$.post("register.php",{'chkuser':chk},function(data){
if(data==" Username already exists.Choose ...
|
I'm trying to use a global JS variable that's dumped on the page by a view/template used to drive a JS solution. This has worked fine in a number of environments, ... |
I've declared an array in a .js file : var newArray = new Array(); after this i added new data to this array in everypage (one data array per page): newArray[1]="AAAA" // here 1 is the page No like page1.htm : : : newArray[n]="ZZZZ". But at the last page(page100.htm) when i try to access newArray[1], it is showing the value as ... |
|
Global Scope of Javascript variables var isCorrect = new Array(); function calc(qNo) { res1=document.form1.r1[0].checked; res2=document.form1.r1[1].checked; res3=document.form1.r1[2].checked; if(res1) { userAns[qNo]=document.form1.r1[0].value; } if(res2) { userAns[qNo]=document.form1.r1[1].value; } if(res3) { userAns[qNo]=document.form1.r1[2].value; } if(userAns[qNo] == answer[qNo]) { isCorrect[qNo]=1 } else isCorrect[qNo]=0 } let me explain the whole program to you. Im creating an assessment engine. Every page contains a question followed by three options (radio buttons). ... |