2016-05-24 61 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',然后获取它。我希望 –