I am trying to figure out if there is a way to open a new browser window when a certain condition is met. A variable would be set to a certain value and placed in either the REQUEST object or the SESSION attribute of the REQUEST object when this condition was met. I know how to do this part. However, I am having trouble figuring out how I can execute some Javascript code when this condition is met. In particular, the Javascript code should open a new window and display a customized message in this window. I also have the Javascript code to do this particular task. How do I call this Javascript code though? Is it possible to place Javascript code in a DTML method? If so, then I could call the method when the condition was met and this would execute the Javascript code. Any help would be greatly appreciated. Thanks. - Asad
----- Original Message ----- From: "Asad Habib" <ahabib@engin.umich.edu>
(...) Is it possible to place Javascript code in a DTML method? If so, then I could call the method when the condition was met and this would execute the Javascript code. Any help would be greatly appreciated. Thanks.
You already had the answer. You can put the javascript code that you need inside a dtml method and call it at will from any script/template that you were using to render the page. Ausum
- Asad
Asad, Maybe something like this? <dtml-var standard_html_header> <h2><dtml-var title_or_id> <dtml-var document_title></h2> <dtml-eval> ascripts = 0 </dtml-eval> <dtml-if ascripts> <SCRIPT LANGUAGE="JavaScript"> <!-- hide from old browsers alert('howdy') // end script hiding --> </SCRIPT> </dtml-if> <dtml-var standard_html_footer> David ----- Original Message ----- From: "Asad Habib" <ahabib@engin.umich.edu> To: <zope@zope.org> Sent: Monday, July 19, 2004 2:38 PM Subject: [Zope] Zope and Javascript
I am trying to figure out if there is a way to open a new browser window when a certain condition is met. A variable would be set to a certain value and placed in either the REQUEST object or the SESSION attribute of the REQUEST object when this condition was met. I know how to do this part. However, I am having trouble figuring out how I can execute some Javascript code when this condition is met. In particular, the Javascript code should open a new window and display a customized message in this window. I also have the Javascript code to do this particular task. How do I call this Javascript code though? Is it possible to place Javascript code in a DTML method? If so, then I could call the method when the condition was met and this would execute the Javascript code. Any help would be greatly appreciated. Thanks.
- Asad _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Asad, I forgot that <dtml-eval> is not a standard product (I use it all the time). Also ascripts = 0 would not activate the javascript because <dtml-if 0> doesn't execute. Sorry about that. P.S. - you can also use DTML to set hidden HTML <form> fields. Then inspect those fields for a value in a JavaScript function, eg ---------------------------------------------------------------------------- ------------------------------------- <script language="Javascript"> function doProcess() { if (document.forms[0].some_switch.value == 'process') { <--------------------------- java alert('test!) ; return false ; } </script> <form ... > <input type="hidden" name="some_switch" value="="&dtml-someVar"> <----------------------------- DTML </form> <a href="" onclick="doProcess();return false;"> <IMG SRC="//btn_left_process" alt="Process" border="0"/></a> ---------------------------------------------------------------------------- -------------------------------- David ----- Original Message ----- From: "David Hassalevris" <bluepaul@earthlink.net> To: "Asad Habib" <ahabib@engin.umich.edu>; <zope@zope.org> Sent: Monday, July 19, 2004 3:29 PM Subject: Re: [Zope] Zope and Javascript
Asad, Maybe something like this?
<dtml-var standard_html_header> <h2><dtml-var title_or_id> <dtml-var document_title></h2> <dtml-eval> ascripts = 0 </dtml-eval>
<dtml-if ascripts> <SCRIPT LANGUAGE="JavaScript"> <!-- hide from old browsers alert('howdy') // end script hiding --> </SCRIPT> </dtml-if>
<dtml-var standard_html_footer>
David ----- Original Message ----- From: "Asad Habib" <ahabib@engin.umich.edu> To: <zope@zope.org> Sent: Monday, July 19, 2004 2:38 PM Subject: [Zope] Zope and Javascript
I am trying to figure out if there is a way to open a new browser window when a certain condition is met. A variable would be set to a certain value and placed in either the REQUEST object or the SESSION attribute of the REQUEST object when this condition was met. I know how to do this part. However, I am having trouble figuring out how I can execute some Javascript code when this condition is met. In particular, the Javascript code should open a new window and display a customized message in this window. I also have the Javascript code to do this particular task. How do I call this Javascript code though? Is it possible to place Javascript code in a DTML method? If so, then I could call the method when the condition was met and this would execute the Javascript code. Any help would be greatly appreciated. Thanks.
- Asad _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Hi, Am Di, den 20.07.2004 schrieb David Hassalevris um 1:25:
Asad,
I forgot that <dtml-eval> is not a standard product (I use it all the time). Also ascripts = 0 would not activate the javascript because <dtml-if 0> doesn't execute. Sorry about that.
P.S. - you can also use DTML to set hidden HTML <form> fields. Then inspect those fields for a value in a JavaScript function, eg ---------------------------------------------------------------------------- ------------------------------------- <script language="Javascript"> function doProcess() {
if (document.forms[0].some_switch.value == 'process') { <--------------------------- java alert('test!) ; return false ; }
</script>
<form ... > <input type="hidden" name="some_switch" value="="&dtml-someVar"> <----------------------------- DTML </form>
<a href="" onclick="doProcess();return false;"> <IMG SRC="//btn_left_process" alt="Process" border="0"/></a>
Better not use an empty href. There are a lot of situations where the user just disabled Javascript for some reason. And this way the site renders itself nonfunctional for no good reason. <a href="alternative_serverside_page" onclick="doOpenYourWindow(); return false;" target="newWindow">... </a> Of course the target and onclick is not for XHTML. Returning false from onXXX-Handler means the browser should not do its default action which is follow the link here. This way both with and without javascript you can use the site. Regards Tino Wildenhain
participants (4)
-
Asad Habib -
Ausum Studio -
David Hassalevris -
Tino Wildenhain