Forum How do I...?

Javascript not being executed. What am I doing wrong ?

marcky
Hi,

I am currently having trouble executing some javascript codes. Nothing seems to happen when the PDF is generated. What I'm trying to do is simply show some contents if like X == Y or whatever. The version I am currently working with is 9.0.

For example let's say I have this (pseudo code) :

<html>

<head>
</head>

<body>

<div id="myElementToBeDisplayed" style="display:none;">Hidding in the underground</div>

<script type="text/javascript" language="JavaScript">
		

		Prince.addEventListener("complete", function(){
			
			document.getElementById("myElementToBeDisplayed").style.display = "block";
			
		}, false);

		
		
</script>

</body>

</html>



This is the most valuable code I tested(got it from the js doc), but nothing seems to be working. Is there anything I should know about running javascript with princexml ?

I also tried to put the code in the <head /> but didn't work..

Any advice?

Thank you for your time,

Marc
mikeday
The oncomplete event is only fired after the PDF has been generated, so at that point changing the DOM will have no effect. You probably want to modify the DOM during the onload event.