DIV has class:testClass.
DIV has class:testClass.
DIV has class:testClass.
DIV has class:noTestClass.
P has class:testClass.
~~~
[html code as follows;]
<div class="testClass">DIV has class:testClass.</div>
<div class="testClass">DIV has class:testClass.</div>
<div class="testClass">DIV has class:testClass.</div>
<div class="noTestClass">DIV has class:noTestClass.</div>
<p class="testClass">P has class:testClass.</p>
~~~
[script code as follows;]
function evalJSInAnotherPage(url){
var httpRequest;
if (window.XMLHttpRequest){
httpRequest = new XMLHttpRequest()
}
else{
if (window.ActiveXObject){
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
}
httpRequest.open('GET', url, false);
httpRequest.send(null);
var result;
var keyword_str;
var keyword_end;
var script_str;
var script_end;
result = httpRequest.responseText;
keyword_str = "class='post-body entry-content'>";
keyword_end = "class='post-footer'>";
script_str = result.indexOf(keyword_str) + keyword_str.length;
script_end = result.indexOf(keyword_end);
result = result.substr(script_str , script_end);
keyword_str = "scrip";
script_str = result.indexOf(keyword_str) + 7;
result = result.substr(script_str);
keyword_end = "<\/scrip";
script_end = result.indexOf(keyword_end);
result = result.substr(0 , script_end);
result = result.replace(/<br \/>/g, "\n").replace(/&/g,"&").replace(/"/g,"\"").replace(/</g,"<").replace(/>/g,">");
eval(result);
}
evalJSInAnotherPage("http://humanbeing-etcman.blogspot.com/2008/10/jquery-126js.html");
$("DIV.testClass").css("color","red")
.animate({fontSize:"2em"},2000)
.html("TestClass was found with DIV.")
~~~
script全体は、以下で変換している。
http://dean.edwards.name/packer/
今回の切り出しは、かなり強引です。
スクリプトをテンプレートに入れない、ブログ環境のみでどこまでできるかの検証です。
スクリプトを埋め込んだページの説明文等、お勧めURLのブックマークを列記すれば、それなりに
オブジェクト的に扱えるかも?
対象のhtmlファイルがwell-formedであれば、XMLパーサで、埋め込んだスクリプトが抜け、
htmlエンコードしたコードのデコードは不要となる模様です。ブログ登録時に自動挿入されるスクリプト内の<br />は\nに変換します。IEではOK。ただし、FireFoxのXMLハンドリングは、htmlに対してうまく動作していない?チェック要!
~~~
The entire script has been converted as follows.
http://dean.edwards.name/packer/
This cutting out is considerably forcible.
It is a verification where being possible to do in a blog environment alone that
doesn't put the script in the template.
As such, if the bookmark of recommendation URL like the explanation on the page where
the script is buried etc. is enumerated, can you treat in the object?
If the html file of the object is well-formed, the buried script will come off by
the XML parser, and the decipherment of the code in which html is encoded become
unnecessary. <br /> in the script inserted automatically when the blog is registered is converted into \n.IE is OK.However, does not the XML handling of FireFox operate well for html? TODO)
~~~
end
0 件のコメント:
コメントを投稿