如何用javascript擷取UUID,javascript擷取UUID

來源:互聯網
上載者:User

如何用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 + "]<&#4......餘下全文>>
 
各位,怎使用javascript實現擷取當前頁面所有內容然後存到指定目錄下

可以使用 document.documentelement.outerhtml 擷取html
可以使用fso = new actinvexobject('Wscript.filesystemobject') 對象來儲存,這個有安全問題,瀏覽器設定比較麻煩

你的需求 具體還得看需求和運行環境

其實 指令碼有很強大的功能,但是也有很大局限性. 要看用在什麼場合下.

很久沒有用這個, 只能給你提供一個思路,具體代碼還得你自己寫.
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.