Inserting code into <head> of document

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

  1. #1

    Default Inserting code into <head> of document

    Hi all,

    It seems that devforums.macromedia.com no longer exists or at least I can't
    connect to it. I have built some easy commands that insert code blocks before
    and made them into extensions but this time I am going to need to write code
    into the head of the document much like doing the "jumpMenu" would. I cannot
    find the command that will do this and I have even tried to pick apart the
    javascript and find where it does this for the actual "jumpMenu" to see how it
    is done but cant.

    Can anyone point me to a good resource or tell me the functions that can do
    this? Thanks in advance.

    Buddy

    buddyq Guest

  2. Similar Questions and Discussions

    1. 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. ...
    2. 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?
    3. 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...
    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: Inserting code into <head> of document

    > Can anyone point me to a good resource or tell me the functions that can do
    > this? Thanks in advance.
    I'm not aware of such a function, but you can still rewrite the whole content of
    the head tag using innerHTML


    Phil Guest

  4. #3

    Default Re: Inserting code into <head> of document

    Okay that sounds like a plan. I didn't think of that. Thanks. The more I get
    into this simple thing i'm going to try to make, the more things I realize I
    have to know.

    I am trying to make an extension for dependant dropdown menus. I have one for
    dynamic dependant but this one should be all javascript based for non-dynamic
    situations. If anyone wants to help I'd love to do this with someone. I know it
    would be very easy for the right person but also very very popular.

    Buddy

    Buddy

    buddyq Guest

  5. #4

    Default Re: Inserting code into <head> of document

    I can do this with 2 lines of code if you are still interested.
    envision3d Guest

  6. #5

    Default Re: Inserting code into <head> of document

    [q]Originally posted by: Newsgroup User
    > Can anyone point me to a good resource or tell me the functions that can do
    > this? Thanks in advance.
    I'm not aware of such a function, but you can still rewrite the whole content
    of
    the head tag using innerHTML


    [/q]

    I would be interested is seeing a simple example on how you would do something
    like this? with a document open, re-write the contents of the head tag. Also,
    what if a head tag wasn't present in the file?

    thanks
    kscap


    kscap Guest

  7. #6

    Default Re: Inserting code into <head> of document

    Well, I don't rewrite the contents of the head tag. I just place my code within it.
    envision3d Guest

  8. #7

    Default Re: Inserting code into <head> of document

    [q]Originally posted by: envision3d
    Well, I don't rewrite the contents of the head tag. I just place my code
    within it.[/q]

    would you be able to provide an example on how you do this?



    kscap Guest

  9. #8

    Default Re: Inserting code into <head> of document

    This will get the head tag in the current document and add it to the
    @@head__tag@@ param

    var heads = dw.getDocumentDOM().getElementsByTagName("head");
    paramObj.head__tag = heads[0];

    You can use this method to find any tag such as the body. This will eliminate
    the need for that annoying tag menu in the extension UI.

    envision3d Guest

  10. #9

    Default Re: Inserting code into <head> of document

    thanks for the example.
    kscap Guest

  11. #10

    Default Re: Inserting code into <head> of document

    [q]Originally posted by: envision3d
    This will get the head tag in the current document and add it to the
    @@head__tag@@ param

    var heads = dw.getDocumentDOM().getElementsByTagName("head");
    paramObj.head__tag = heads[0];

    You can use this method to find any tag such as the body. This will eliminate
    the need for that annoying tag menu in the extension UI.[/q]
    how would you rewrite this to the document in the proper place?



    kscap Guest

  12. #11

    Default Re: Inserting code into <head> of document

    What do you mean? This code goes in the javascript function applyServerBahavior().
    envision3d Guest

  13. #12

    Default Re: Inserting code into <head> of document

    [q]Originally posted by: envision3d
    What do you mean? This code goes in the javascript function
    applyServerBahavior().[/q]

    well, what i was looking to do was inside DW when a user executes a custom
    command, it would inject some code, say a CSS link or some style info into the
    header of the currently open document. Or something to attach a CSS to a
    document. The purpose is to have the least amount of user interaction, maybe
    just a simple shortcut key and this would execute the code to do what i
    mentioned.



    kscap Guest

  14. #13

    Default Re: Inserting code into <head> of document

    Well then you would place that inside the applyCommand() function. And don't
    forget: When you start including links to files like .css you must keep track
    of the file relative to the document they are working on. The ol' ../../
    stuff. If they are working on a page that is 5 folders down from where the .cc
    file is, you would have to have ../../../../../ placed in front of you .css
    file. It gets very tricky.

    envision3d Guest

  15. #14

    Default Re: Inserting code into <head> of document

    cool man thanks for the heads up.
    kscap 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