2017-06-22 41 views
0

我使用此代碼,打開頂點模態對話框頁但是當我使用「」這樣當我想使用eval()打開頂端的網址,我得到的打擊錯誤

var url='f?p=101:7:&SESSION.::::&P7_ID,&P7_ALLOWCHANGE,&P7_WFDEF_ID:8461,1,69004'; 

    eval(url); 

我得到這個錯誤(

SyntaxError: missing ; before statement 

) 當使用 「」

var url="f?p=101:7:&SESSION.::::&P7_ID,&P7_ALLOWCHANGE,&P7_WFDEF_ID:8461,1,69004"; 

    eval(url); 

我得到這個錯誤

SyntaxError: expected expression, got ':' 

這項工作很好,當不傳遞任何參數

請如果有誰知道anythings幫助我,我需要的是

感謝

+2

在JS ['eval'](https://developer.mozilla.org/en/ docs/Web/JavaScript/Reference/Global_Objects/eval)用於評估包含JavaScr的字符串ipt代碼 - 一般不應該做的事情,但你的url變量不包含任何JavaScript代碼。這是不是很清楚爲什麼你想/不得不使用'eval'。 –

+0

@ t.niese,我該怎麼辦? url是頂點url格式 – saman

+0

@ t.niese我沒有太多的技能,我在網站上看到eval並使用它 – saman

回答

0

那麼,當你使用eval你把文字串和eval像代碼一樣執行它也必須在文字代碼行中包含「=」。

如果行動已經沒有操作=比:

的eval( 「VAR ANYTHING = someFunction()」)

在代碼段重定向可以做到的,因爲不存在的鏈接!

// if this is your new url 
 
var url="www.YOURWEBSITE.com"; 
 

 
url = url + "f?p=101:7:&SESSION.::::&P7_ID,&P7_ALLOWCHANGE,&P7_WFDEF_ID:8461,1,69004"; 
 

 
setTimeout( function() { 
 

 
eval ("window.location = url") 
 

 
} , 5000)
AFTER 5 SEC YOU WILL BE REDIRECTED

工作片段:

function iframeRef(frameRef) { 
 
    return frameRef.contentWindow 
 
     ? frameRef.contentWindow.document 
 
     : frameRef.contentDocument 
 
} 
 

 
var YOURPAGE_window = document.getElementById("windows"); 
 

 
var url="https://maximumroulette.com/webgl2"; 
 

 

 
setTimeout( function() { 
 

 
YOURPAGE_window.src = url; 
 
//eval ("iframeRef(YOURPAGE_window).location.href = url") 
 

 
} , 5000)
Worked (update)! 
 

 
You will be redirected 
 

 

 

 

 
<iframe id="windows" src="https://maximumroulette.com" ></iframe>

相關問題