2016-05-24 78 views
0

我附加了外部js文件,每次訪問時都會發生變化。 這是我的文件。從外部動態加載的js文件解析信息

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Damn</title> 
</head> 
<body> 
<script async="" src="//xx.example.net/checkInventory.php?_=&amp;v=3&amp;siteId=1059123&amp;minBid=0&amp;popundersPerIP=0&amp;blockedCountries=&amp;documentRef=&amp;s=1600,900,1,1600,900" type="text/javascript"></script> 

</body> 
</html> 

這是迴應時,我在瀏覽器中鍵入此xx.example.net/.....鏈接:

window._pao.parse({ 'result': 1, 'url': 'http://example.com/', 'bla': 'bla', 'bla': 1 }); 

我想在我的代碼簡單地解析這個url。我該如何處理這個問題?

+1

我很困惑。請提供更多關於您嘗試過的信息,以及'window._pao.parse'是什麼? –

+0

老實說,我不知道什麼是地獄window._pao.parse是,這就是爲什麼我張貼here.I試圖得到這個附加的文件與PHP(file_get_contents)來解析url,但響應是空的。 –

+0

代碼行是從哪裏來的? –

回答

0

基於你在這裏所提供的有限信息是我最好的猜測你想要什麼:

<script> 
    window._pao = {} 
    window._pao.parse = function (object){ // Declare the window._pao.parse function in order to capture the object 
     // Here object = { 'result': 1, 'url': 'http://example.com/', 'bla': 'bla', 'bla': 1 } 
     // Do stuff with object here 
     document.write(object.url) 
    } 
</script> 
<script src="path/to/your/external/js/file.js"></script> 
+0

但這是重寫功能。 –

+0

@AskingQuestions你會如何獲得對象? – 2426021684

+0

將'window._pao.parse'更改爲'var window._pao.parse',然後獲取它。我希望 –