如何用javascript擷取UUID,javascript擷取UUID
由於javascript是單線程的東西,所以我們放一個累加變數作為id也不會重複.
但其實javascript本身提供了可以獲得唯一id的東東.還記得setTimeout()方法會返回一個唯一id用來後來清除定時器,我們不妨就借用這個id吧.
function getUUID() { var id = setTimeout('0'); clearTimeout(id); return id;};
怎用JavaScript擷取當前頁面的網址?
<table width=100% cellpadding=0 cellspacing=0 border=0 >
<script language="javascript">
thisURL = document.URL;
thisHREF = document.location.href;
thisSLoc = self.location.href;
thisDLoc = document.location;
strwrite = "<tr><td valign=top>thisURL: </td><td>[" + thisURL + "]</td></tr>"
strwrite += "<tr><td valign=top>thisHREF: </td><td>[" + thisHREF + "]</td></tr>"
strwrite += "<tr><td valign=top>thisSLoc: </td><td>[" + thisSLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisDLoc: </td><td>[" + thisDLoc + "]</td></tr>"
document.write( strwrite );
</script>
thisDLoc = document.location; <BR>
thisURL = document.URL; <BR>
thisHREF = document.location.href; <BR>
thisSLoc = self.location.href;<BR>
<script language="javascript">
thisTLoc = top.location.href;
thisPLoc = parent.document.location;
thisTHost = top.location.hostname;
thisHost = location.hostname;
strwrite = "<tr><td valign=top>thisTLoc: </td><td>[" + thisTLoc + "]</td></tr>"
strwrite += "<tr><td valign=top>thisPLoc: </td><td>[" + thisPLoc + "]<......餘下全文>>
各位,怎使用javascript實現擷取當前頁面所有內容然後存到指定目錄下
可以使用 document.documentelement.outerhtml 擷取html
可以使用fso = new actinvexobject('Wscript.filesystemobject') 對象來儲存,這個有安全問題,瀏覽器設定比較麻煩
你的需求 具體還得看需求和運行環境
其實 指令碼有很強大的功能,但是也有很大局限性. 要看用在什麼場合下.
很久沒有用這個, 只能給你提供一個思路,具體代碼還得你自己寫.