{"action":"opened","issue":{"url":"https://api.github.com/repos/florentbr/SeleniumBasic/issues/44","labels_url":"https://api.github.com/repos/florentbr/SeleniumBasic/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/florentbr/SeleniumBasic/issues/44/comments","events_url":"https://api.github.com/repos/florentbr/SeleniumBasic/issues/44/events","html_url":"https://github.com/florentbr/SeleniumBasic/issues/44","id":120726966,"number":44,"title":"How to override PhantomJS onInitialized Global object to run specific tasks every time new webpage is created but before a URL is loaded.","user":{"login":"zaka786khan","id":7099671,"avatar_url":"https://avatars.githubusercontent.com/u/7099671?v=3","gravatar_id":"","url":"https://api.github.com/users/zaka786khan","html_url":"https://github.com/zaka786khan","followers_url":"https://api.github.com/users/zaka786khan/followers","following_url":"https://api.github.com/users/zaka786khan/following{/other_user}","gists_url":"https://api.github.com/users/zaka786khan/gists{/gist_id}","starred_url":"https://api.github.com/users/zaka786khan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zaka786khan/subscriptions","organizations_url":"https://api.github.com/users/zaka786khan/orgs","repos_url":"https://api.github.com/users/zaka786khan/repos","events_url":"https://api.github.com/users/zaka786khan/events{/privacy}","received_events_url":"https://api.github.com/users/zaka786khan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-07T09:01:08Z","updated_at":"2015-12-07T09:01:08Z","closed_at":null,"body":"Hi Dear florentbr!\r\n\r\nThanks allot for replying last issues which I submitted due to being newbie. As I come to know that PhantomJS driver offers onInitialized callback is invoked after the web page is created but before a URL is loaded. The callback may be used to change global objects. \r\n\r\nI want to know how can we override this object to let our source/piece of code to be run every time once a new webpage object is created before the URL is loaded. I want to add some methods/functions to be run on webpage is created. \r\n\r\nfor example clicking on a[_blank] link cause open new page but before created the new page my code may be run once.\r\n\r\nAs described at http://phantomjs.org/api/webpage/handler/on-initialized.html\r\nvar webPage = require('webpage');\r\nvar page = webPage.create();\r\n\r\npage.onInitialized = function() {\r\n  page.evaluate(function() {\r\n    document.addEventListener('DOMContentLoaded', function() {\r\n      console.log('DOM content has loaded.');\r\n    }, false);\r\n  });\r\n};\r\n\r\nBut how do I add some code to be run once the webpage instance is initialized in SeleniumBasic 2.0.6 using VBA or VB6. \r\n\r\nThanks"}}