Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. initialize the variable with image tag

initialize the variable with image tag

Scheduled Pinned Locked Moved JavaScript
help
4 Posts 3 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manikumar_gutti
    wrote on last edited by
    #1

    hi, I have a problem with this code. if you understand this please send me the explantion. I dont understand the variable intialization. could u please tell me what it means. var openImage = "" function getPath(url) { lastSlash = url.lastIndexOf("/") return url.substring(0, lastSlash + 1) } regards manikanta

    L 1 Reply Last reply
    0
    • M manikumar_gutti

      hi, I have a problem with this code. if you understand this please send me the explantion. I dont understand the variable intialization. could u please tell me what it means. var openImage = "" function getPath(url) { lastSlash = url.lastIndexOf("/") return url.substring(0, lastSlash + 1) } regards manikanta

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Assuming url contains something like "dir/subdir/filename" then you will get the following:

      openImage = ![](filenamedg
      closeImage = .gif)

      // so putting them together will create the string

      I must get a clever new signature for 2011.

      P 1 Reply Last reply
      0
      • L Lost User

        Assuming url contains something like "dir/subdir/filename" then you will get the following:

        openImage = ![](filenamedg
        closeImage = .gif)

        // so putting them together will create the string

        I must get a clever new signature for 2011.

        P Offline
        P Offline
        parths
        wrote on last edited by
        #3

        var openImage = "<IMG SRC=\"" + getPath(location.href) + "dg"
        var closeImage = ".gif\" HEIGHT=21 WIDTH=16>"

        function getPath(url)
        {
        lastSlash = url.lastIndexOf("/")
        return url.substring(0, lastSlash + 1)
        }

        The code uses location.href, so I think it's looking for a file name dg.gif in the same folder as the web-page being referenced.

        Richard MacCutchan wrote:

        I think (assuming my page is 'http://mywebdomain/myfolder/mypage.html') this would be:

        <IMG SRC="http://mywebdomain/myfolder/dg.gif" HEIGHT=21 WIDTH=16>

        "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

        L 1 Reply Last reply
        0
        • P parths

          var openImage = "<IMG SRC=\"" + getPath(location.href) + "dg"
          var closeImage = ".gif\" HEIGHT=21 WIDTH=16>"

          function getPath(url)
          {
          lastSlash = url.lastIndexOf("/")
          return url.substring(0, lastSlash + 1)
          }

          The code uses location.href, so I think it's looking for a file name dg.gif in the same folder as the web-page being referenced.

          Richard MacCutchan wrote:

          I think (assuming my page is 'http://mywebdomain/myfolder/mypage.html') this would be:

          <IMG SRC="http://mywebdomain/myfolder/dg.gif" HEIGHT=21 WIDTH=16>

          "It was when I found out I could make mistakes that I knew I was on to something." -Ornette Coleman "Philosophy is a study that lets us be unhappy more intelligently." -Anon.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You are right of course, I misread the getPath() function.

          I must get a clever new signature for 2011.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups