2

我正在尝试构建一个执行以下操作的书签:

1.)加载位于我的服务器上的外部js(完成)

javascript:function%20loadScript(scriptURL)%20{%20var%20scriptElem%20=%20document.createElement('SCRIPT');%20scriptElem.setAttribute('language',%20'JavaScript');%20scriptElem.setAttribute('src',%20scriptURL);%20document.body.appendChild(scriptElem);}%20loadScript('http://127.0.0.1/main.js?x='+Math.random());

2.)这个外部javascript依次加载jquery和jquery ui,而不是在当前站点DOM中添加一个div。(不能让它工作)

function loadScripts(scriptURL) {


 var scriptElem = document.createElement('SCRIPT');
 scriptElem.setAttribute('language', 'JavaScript');
 scriptElem.setAttribute('src', scriptURL);
 void(document.body.appendChild(scriptElem));
}


loadScripts('http://127.0.0.1/js/jquery-1.3.2.min.js');
loadScripts('http://127.0.0.1/js/jquery-ui-1.7.2.custom.min.js');


var head = document.getElementsByTagName('head')[0]; 
$(document.createElement('link')).attr({type: 'text/css', href: 'http://127.0.0.1/css/redmond/jquery-ui-1.7.2.custom.css', rel: 'stylesheet'}).appendTo(head);



$(document).ready(function(){
    div = $("<div>").html("Loading......");
    $("body").prepend(div);
});

我遇到的问题是我无法附加具有特定 id 的 div,这个想法是使用 jqueryui 的 dialog() 函数,以便在我使用书签的任何站点上出现一个可调整大小的可移动对话框.

$("#dialog").dialog(); 

正如您可以想象的那样,我需要将我的内容加载到特定的 div 中,这样我就不会弄乱加载小书签的网站的设计。

3.)刚刚打开的对话框有一个远程php文件的内容,基本上是解析页面。

脚本完成了,我只需要将它加载到我正在尝试构建的对话框中。

请帮忙,因为我真的被这个困住了!谢谢。

4

1 回答 1

1

这有帮助吗?这是给你带来问题的部分吗?

$("<div id='id'></div>").html("Loading......");

jQuery 文档说:

所有 HTML 必须格式正确,否则可能无法在所有浏览器中正常工作。这包括$("<span>")可能不起作用但$("<span/>")会起作用的情况(注意 XML 样式的右斜杠)。

于 2009-12-21T10:13:10.917 回答