Gocha Kereselidze Gocha Kereselidze - 6 months ago 13
Javascript Question

Parse information from external dynamically loaded js file

I have attached external js file which one changes on every visit.
this is my file.

<!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>


this is response when i type this xx.example.net/..... link in my browser :

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


I want to simply parse this url in my code.How can i handle this problem?

Answer

Based on the limited info you provided here is my best guess at what you want:

<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>
Comments