Richard Korts
asked on
Don't understand why HTML / Javascript code does what it does
I have this code, a small snippet of a much larger program:
I have run this in Chrome with the debugger on . It shows no exceptions.
The full page loads & sits, which is what it should do AFTER it goes to sel_save.php, that program updates the database with some things, then returns to here.
But how can the alert be avoided.
function save_proj() {
alert("sesname = " + sessname);
if (ps != "Y") {
if (save_sel == 1) {
window.location = "sel_save.php?fr=";
}
}
}
function chk_skip_summ() {
if (nosumm == "1") {
window.location = "send_email_ls250.php?ddocs=" + ddocs;
}
save_proj();
chk_ems();
set_pointers();
//show body
document.getElementById("container").style.visibility = 'visible';
}
</script>
<!-- Global site tag (gtag.js) - Google
Analytics -->
<script async
src="https://www.googletagmanager.com
/gtag/js?id=UA-96994211-3"></script>
<script>
window.dataLayer = window.dataLayer
|| [];
function
gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-96994211-3');
</script>
</head>
<body onLoad="save_proj(); chk_ems(); set_pointers();">
I have run this in Chrome with the debugger on . It shows no exceptions.
The full page loads & sits, which is what it should do AFTER it goes to sel_save.php, that program updates the database with some things, then returns to here.
But how can the alert be avoided.
Use console.log instead of alert. The built-in alert, confirm, and prompt dialogs are all synchronous, that is they prevent the currently executing JS code from processing until they are closed.
ASKER
What is console.log? Where do I find info on that.
In my experience, the alert will STOP the processing, which is exactly what I want it to do.
I am almost positive if I created a simple HTML page with just the body onLoad = & the Javascript, it will work perfectly. The Chrome console debugger shows nothing.
In my experience, the alert will STOP the processing, which is exactly what I want it to do.
I am almost positive if I created a simple HTML page with just the body onLoad = & the Javascript, it will work perfectly. The Chrome console debugger shows nothing.
Oh, if you wanted the alert() for that purpose...
Anyway, Mozilla Developer Network (MDN) is an excellent resource for information on JS and CSS. Here's its page for console.log().
Where are the "ps" and "save_sel" variables set?
Anyway, Mozilla Developer Network (MDN) is an excellent resource for information on JS and CSS. Here's its page for console.log().
Where are the "ps" and "save_sel" variables set?
ASKER
Hi David,
Attached is the FULL rendered HTML. The original is in php. This shows you where all the Javascript variables, etc. are set.
Thanks,
Richard
summary.html
Attached is the FULL rendered HTML. The original is in php. This shows you where all the Javascript variables, etc. are set.
Thanks,
Richard
summary.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, those are very useful. I can’t get to this till tomorow, maybe Monday.
Richard
Richard