2013-02-19 83 views
-2

這是我的代碼:的JavaScript/HTML可變麻煩

<HTML> 
    <HEADER> 
     <TITLE>Page</TITLE> 
    </HEADER> 
<SCRIPT LANGUAGE="JavaScript"> 
var asdf=Math.floor(Math.random()*80000000) 
</SCRIPT> 
<FORM> 
<input type=button 
value="button" 
onClick="self.location='http://www.roblox.com/place-place?id=$_GET["var asdf"]'"> 
</FORM> 
    <BODY> 
    </BODY> 
</HTML> 

如何解決它,因此鏈接是隨機的,但也適用?

回答

0
try this 

<HTML> 
<HEADER> 
<TITLE>Page</TITLE> 
</HEADER> 
<SCRIPT LANGUAGE="JavaScript"> 
function my_func() 
{ 
var asdf= Math.floor(Math.random()*80000000); 
window.open("http://www.roblox.com/place-place?id="+asdf); 
} 

</SCRIPT> 
<FORM> 
<input type=button value="button" onClick="my_func()"> 
</FORM> 
<BODY> 
</BODY> 
</HTML> 

you can also use window.location instead of window.open. 
2

變化onclick的值:

"var asdf=Math.floor(Math.random()*80000000); window.location='http://www.roblox.com/place-place?id='+asdf" 

這將隨機鏈接

0

使用函數的每次點擊的ID,

function redirect(){ 
self.location='http://www.roblox.com/place-place?id='+asdf; 
} 

的通話功能的onclick的輸入標籤