Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add JavaScript Code to head

New Here ,
Feb 20, 2008 Feb 20, 2008
We use a customized button for submitting forms or links at work. The code combines DHTML elements for the look and functionality of the button. I've created an extension, and it adds the HTML and CSS code, but when I try to add the JavaScript, I get an error because DreamWeaver tries to parse the JavaScript as a part of the extension.

I can't figure out how to get the JavaScript into the <head> of the document like the CSS. I've looked at numerous functions and I just can't find enough documentation to get a full understanding. Any help is greatly appreciated.
TOPICS
Extensions
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2008 Feb 20, 2008
figmentthinking wrote:
> We use a customized button for submitting forms or links at work. The code
> combines DHTML elements for the look and functionality of the button. I've
> created an extension, and it adds the HTML and CSS code, but when I try to add
> the JavaScript, I get an error because DreamWeaver tries to parse the
> JavaScript as a part of the extension.
>
> I can't figure out how to get the JavaScript into the <head> of the document
> like the CSS. I've looked at numerous functions and I just can't find enough
> documentation to get a full understanding. Any help is greatly appreciated.
>


You have not given much to go on, but it might be that you did not
realize that any '</script>' tags needed to be masked from DW Extension
API by breaking them up into '</scr'+'ipt>'

--


E. Michael Brandt

www.divahtml.com
www.divahtml.com/products/scripts_dreamweaver_extensions.php
Standards-compliant scripts and Dreamweaver Extensions

www.valleywebdesigns.com/vwd_Vdw.asp
JustSo PictureWindow
JustSo PhotoAlbum, et alia

--
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2008 Feb 21, 2008
Michael,

Thanks for the reply. I find the documentation lacking, I can concede that maybe it's my understanding of what's provided, but more explanation would be better.

Simply put, I have a css that needs to be in the style tags and JavaScript that needs to be in the head, and HTML that needs to be in the body tag.

Leaving the JS out of the equation, my simple .htm file with the CSS and HTML find their appropriate spots in the doucment I'm working on.

I attempted to escape the closing script tag in the .htm file , but that doesn't work (this is where I think the documentation should explain that has to be in a .js file) , but documentation also lacks in how to get the data from the JS file back into the document.

I think my biggest issue is that I'm working from with in the DW API, which could be programmed to do what ever they want it to do, and knowing this I'm leaving the normal thought process of HTML and JavaScript, and I'm trying to guess a what could be.

I've managed to copy code and get a positive result, but it looks like I'm going to have to recode the entire .htm file and pass it as a string to the JavaScript so it will return all 3 DHTML elements to the document. That just seems like too much work.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 21, 2008 Feb 21, 2008
LATEST
You have not said, but I gather you are using the Command API, which is
the most flexible and powerful of the three: Behavior, Object and
Command APIs.

With that API, you can simply add to the innerHTML of the Head (or the
"head" Editable Region of a Child page, or NOT the "head" editable
region of a Template) a string containing your new script, as long as
you break up the </script> tag. To be safe I often break up the opening
<script> tag too.

So, for example:

var str='<scr'+'ipt type="text/javascript"> blah blah</scr'+'ipt>';

var head=dw.getDocumentDOM().getElementsByTagName('HEAD')[0];
head.innerHTML=head.innerHTML+str;

--


E. Michael Brandt

www.divahtml.com
www.divahtml.com/products/scripts_dreamweaver_extensions.php
Standards-compliant scripts and Dreamweaver Extensions

www.valleywebdesigns.com/vwd_Vdw.asp
JustSo PictureWindow
JustSo PhotoAlbum, et alia

--
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines