View Full Version : Generic Drag Script doesn't work in child window

10-24-2005, 02:53 PM
I'm using the Generic drag script for a <div> layer in a child window. The drag script is in the parent window and I can't seem to access this script from the child window's layer. I can attach the script to anything in the parent window and it works fine... just not from the child window. I've tried referencing the parent script any number of ways unsuccessfully. Can anyone point me in the right direction?


10-24-2005, 03:42 PM
Do you mean parent/child as in two separate windows or as in a window with a frame or iframe on it?


Added later. I looked into this a bit more since I first posted. If you mean a separate window, you would be better off putting the script on the page where you want to use it. Even in a frame or iframe this would be the case. The script uses so many references to the page that it is on that, even though you can access it from another page, it (the script) will have difficulty accessing that second page where your 'dragable' content is.

10-25-2005, 12:47 PM
I've tried to incorporate the generic move text into my child window but have encountered the following problem. The child window, and the <div> layer which I'm trying to attach the move script to, is dynamically created by javascript within the parent window. Whenever I try to insert <script></script> tags into the generated content (with or without the .js move code), the window throws an error and won't render. It's almost as if the <script> tags are reserved and can't be embedded in the dynamic text. Any ideas?

10-25-2005, 02:28 PM
It just stands to reason that if you have something like this:

<script type="text/javascript">
document.write('<script src="generic_drag.js" type="text/javascript"></script>')

The script parser will think that the script is over when it hits the first </script>, making the document.write statement invalid, due to an unterminated string variable or literal (depending on the parser). If instead you break it up, like:

<script type="text/javascript">
document.write('<script src="generic_drag.js" type="text/javascript"><' + '/' + 'script>')

Then the script will only see the last </script> as the end of the script.

10-26-2005, 01:25 PM
Thanks for the suggestion.... breaking the tag script up worked perfectly! The layer in the child window slides around like it's on glass now.