I wanted to auto-fill a form on a web page. I wrote the javascript code for that, and it is working fine. When I visit the web page manually and run the JS code in the console, it works. But I need this JS code to be run from a server by a PHP code. So I'd like to echo this javascript to the specified URL.
Basically, I want a PHP file on a server (with no browser environment) to run a javascript code on a webpage , using echo . I know how to echo HTML/JS from PHP, but I want it to run on a specific web page. Since there is no browser involved I can't use the JS code window.location.href=url to do this.
Here's the PHP code to echo the JS:
echo " <html>
<head>
<script src="../js/xyz.js"></script>
</head>
<body onload="tmp()">
<script type="text/javascript">
function tmp(){
// FIRST VISIT THE URL AND THEN RUN BELOW FUNCTION
someJSfunction("12345","0019");
}
</script>"
</body>
</html>
"
;
Aucun commentaire:
Enregistrer un commentaire