簡體   English   中英

腳本未檢測到Javascript src變量

[英]Javascript src Variable Not Detected by Script

腳本文件和jsfile一起位於Apache主頁服務器上。 在index.html的開頭部分,我們有

 <script type="text/javascript" src="someurl/jsfile.js"></script/>

在腳本文件中,我們通過以下方式引用jsfile

function init_disp() {array_len = jsfile.length...

在有或沒有someurl的情況下運行腳本文件都會產生“'jsfile'is undefined”錯誤。 這里是否存在問題,或者如果服務器軟件正在阻止腳本,是否通過使變量為空來完成?

將IE11與64位Java增強保護和64位增強保護一起使用。 編輯:整個腳本文件(不是我自己的)是這樣的:

    addEvent(window,"load",init_disp);
    addEvent(document,"click",show_init);
    // function to add an event listener
    function addEvent(o,e,f) {
    if (o.addEventListener) {
    o.addEventListener(e,f,false);
    return true;
    }
    else if (o.attachEvent) {
    return o.attachEvent("on"+e,f);
    }
    else {
    return false;
    }
    }
    // integer "random()"
    function rand (n)
    {
    return (Math.floor( Math.random ()*n));
    }
    // BEGIN customization settings
    var char_pause = 60; // pause on each character, milliseconds
    var quote_pause = 8000; // pause to show complete quote, milliseconds
    // END customization settings
    var quoteindex;
    var quote,attribution;
    var pos;
    var box;
    var array_len;
    var quote_len,attrib_len;
    var interval = null;
    var busy;
    var cursor_span = "<span class=\"quotefont quotecursor\">";
    var hide_span = "<span class=\"quotefont hidecolor\">"
    var attr_div = "<p></p><div class=\"quotefont attrib\">";

    function init_disp() {
    array_len = jsfile.length;
    box = document.getElementById("quotebox");
    quoteindex = rand(array_len);
    show_init();
    }
    function show_init() {
    busy = false;
    clearInterval(interval);
    quote_array = jsfile[quoteindex].split("\t");
    quote = quote_array[0];
    attribution = quote_array[1];
    quote_len = quote.length;
    attrib_len = attribution.length;
    quoteindex = (quoteindex+1) % array_len;
    pos = 0;
    interval = setInterval('show_quote()',char_pause);
    }
    function show_quote() {
    pos++;
    if(!busy) {
    busy = true;
    if(pos <= quote_len) {
      box.innerHTML = quote.substring(0,pos) +
      cursor_span +
      quote.substring(pos,pos+1) +
      "</span>" +
      hide_span +
      quote.substring(pos+1) +
      "</span>";
    }
    busy = false;
    }
    if(pos > quote_len) {
    pos = 0;
    clearInterval(interval);
    interval = setInterval('show_attr()',char_pause);
    }
    }
    function show_attr() {
    pos++;
    if(!busy) {
    busy = true;
    if(pos <= attrib_len) {
      var attr = attribution.substring(0,pos);
      box.innerHTML = quote + attr_div + attr + "</div>";
    }
    busy = false;
    }
    if(pos > attrib_len) {
    clearInterval(interval);
    interval = setInterval('show_init()',quote_pause);
    }
    }

使用<script>標記加載Javascript文件時,該文件將被執行,而不是作為Javascript對象加載。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM