Add JavaScript Code to head

Ask a Question related to Macromedia Exchange Dreamweaver Extensions, Design and Development.

  1. #1

    Default Add JavaScript Code to head

    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.

    figmentthinking Guest

  2. Similar Questions and Discussions

    1. add some code to the page <HEAD>
      Is it possible that my user control can add code to the HEAD of the parent page that hosts the control?
    2. Insert Code Into Head
      Hi, I just started creating my own extensions. I'm just wondering how I can make an object extension insert code into multiplae areas of the...
    3. writing dynamic .css into head tag with javascript
      Hello! I have a problem regarding writing to head tag. Here is the situation: I have a page with link tag that points to .css which has screen...
    4. Code into head tag
      Here's a way to get a Title into the Head section using code behind: How do I set the title of an aspx page programmatically...
    5. Injecting code into the <head></head> section
      Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that...
  3. #2

    Default Re: Add JavaScript Code to head

    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

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

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

    --
    E Michael Brandt Guest

  4. #3

    Default Re: Add JavaScript Code to head

    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.

    figmentthinking Guest

  5. #4

    Default Re: Add JavaScript Code to head

    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('HEA D')[0];
    head.innerHTML=head.innerHTML+str;

    --


    E. Michael Brandt

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

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

    --
    E Michael Brandt Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139