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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. How does the "src" tag in javascript work?

How does the "src" tag in javascript work?

Scheduled Pinned Locked Moved Web Development
javascriptdata-structurestoolsquestion
2 Posts 2 Posters 0 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.
  • T Offline
    T Offline
    Tal Rashas Guardianship
    wrote on last edited by
    #1

    In JScript1.js, I defined a function like this: ================================================= var count = 0; function changeDefaultStatus() { var arr = new Array("haoyong", "hao123", "12wangzhi", "123", "state"); if (count >= 5) count = 0; top.defaultStatus = arr[count]; count++; } ================================================= And use the function like this: ================================================= //the code below does not work <script> setInterval("changeDefaultStatus();", 2000); ....... //But if I move the code to here, it works setInterval("changeDefaultStatus();", 2000); ==================================================== when a page is being loaded, how does the "src" works? the explorer will wait for "JScript1.js"'s loading, or just load it in the background. Thank you

    G 1 Reply Last reply
    0
    • T Tal Rashas Guardianship

      In JScript1.js, I defined a function like this: ================================================= var count = 0; function changeDefaultStatus() { var arr = new Array("haoyong", "hao123", "12wangzhi", "123", "state"); if (count >= 5) count = 0; top.defaultStatus = arr[count]; count++; } ================================================= And use the function like this: ================================================= //the code below does not work <script> setInterval("changeDefaultStatus();", 2000); ....... //But if I move the code to here, it works setInterval("changeDefaultStatus();", 2000); ==================================================== when a page is being loaded, how does the "src" works? the explorer will wait for "JScript1.js"'s loading, or just load it in the background. Thank you

      G Offline
      G Offline
      Graham Breach
      wrote on last edited by
      #2

      Every opening </code> tag requires a closing <code> tag, including the one with src="". The opening </code> you have with the <code>src="./JScript1.js"</code> attribute is being closed by the <code> that is after the setInterval call. Any code within that has a src attribute is ignored.

      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