Hi Gergely
I agree that document.write is a bad idea. Freezing in this case may be
a poor choice of words. I was trying to convey that the code executes OK
until it gets to the .write line and hangs up. It never completes the
.write line.
As for purpose. Main.html is a template contains the permanent headers
and footers for the site with the body consisting of an iframe
containing a {% block content %} {% endblock %} statement. When each
button is pushed, all buttons are disabled and the .html template file
associated with the particular button is used to fill the block
content. This worked when I didn't use javascript to call welcome.html.
But I can't seem to figure out how to serve up the file with javascript.
I really don't want to change the general method. I have never liked web
sites that allow users to hit the same button twice or hit more than one
button in mid load. I know that one can build buttons using link but
this seemed more straight forward to me. ie have the button call a
javescript function and let the function do all of the heavy lifting.
I've had many years of various levels of programming and system
maintenance but have been retired since 1998 and am pretty rusty. In
addition, the technology has shifted significantly since. So for all
practical purposes I'm an nooby and am trying to master python, html,
javascript and django all at the same time. Learning by doing I guess.
So the bottom line is that I need a code snippet to put under case b1
that will insert welcome.html into the block statement in main.html.
Any help will be sincerely appreciated.
Gary R.
On 12/13/2015 10:55 PM, Gergely Polonkai wrote:
Sorry, I have pressed Send too soon…
As you see, using document.write is a very bad idea. However, freezing
is not mentioned in that document. What does freezing mean in this
case? Are you sure it's this code that gets executed and freezes?
Also, what exactly do you want to achieve?
Best,
Gergely
On Dec 14, 2015 7:52 AM, "Gergely Polonkai" <[email protected]
<mailto:[email protected]>> wrote:
Hello,
although this is barelyDjango related, here are some notes.
From MDN[1]: Note: as* document.write* writes to the document
*stream*, calling *document.write* on a closed (loaded) document
automatically calls*document.open* which will clear the document
<https://developer.mozilla.org/en-US/docs/Web/API/document.open#Notes>.
[1] https://developer.mozilla.org/en-US/docs/Web/API/Document/write
On Dec 14, 2015 1:22 AM, "Gary Roach" <[email protected]
<mailto:[email protected]>> wrote:
I use javascript in my main.html (top template) to control
the access to several buttons. The buttons call a javascript
function. This setup works exactly as I wish except the
buttons still don't really do anything. I need to have each
button load a different template. The pertinent script is:
<script type="text/javascript">
"use strict"
var bn = ""
function buttoncontrol(bn){
var i = 0;
var bx = "";
var x = []; /*array*/
if (bn=="resetDone")
{
for (var i = 0; i < 4; i++)
{
bx= "b" + (i+1);
document.getElementById(bx)
.removeAttribute("disabled");
}
return
}
else {
for (var i = 0; i < 4; i++)
{
bx= "b" + (i+1);
document.getElementById(bx)
.setAttribute("disabled", "true");
}
switch(bn) {
case "b1":
document.write("<a href=
'welcome.html'>'Welcome.html'</a>");
break;
case "b2":
break;
case "b3":
break;
case "b4":
break;
default:
document.write("fell out the bottom");
}
return;
}
}
</script>
The code works till it hits the document.write statement and
freezes. This just plain doesn't work. What would. I want to
keep this approach, so I need an alternative to the
document.write statement.
Both my main.html and my welcome.html are in the same template
directory. I bypassed the button during development and the
two pages worked well together.
Django 1.8
Python 3.4
Gary R.
--
You received this message because you are subscribed to the
Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from
it, send an email to [email protected]
<mailto:django-users%[email protected]>.
To post to this group, send email to
[email protected]
<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/566E0BC0.8020100%40verizon.net.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CACczBUJERe5jZR37%3DjBF3N7QMRiwR6kWNRWO%3DzxG273EzCLsDQ%40mail.gmail.com
<https://groups.google.com/d/msgid/django-users/CACczBUJERe5jZR37%3DjBF3N7QMRiwR6kWNRWO%3DzxG273EzCLsDQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/566F00AC.5060901%40verizon.net.
For more options, visit https://groups.google.com/d/optout.