[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Run JavaScript Function Remotely with PHP

Posted on 2009-04-14
2
Medium Priority
?
426 Views
Last Modified: 2012-05-06
If I have a PHP script that loads the content of an external HTML page, for instance:
fopen("http://www.example.com", "r");

Is it possible to execute JavaScript commands that exist on that page? For example, if a button exists on that page like:
<a href="" onclick="javascript...">Link</a>

Could I run that JavaScript from my PHP script?
0
Comment
Question by:EMB01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Expert Comment

by:striker46
ID: 24138754
PHP is server side, JS is client side. You cannot run JS directly in PHP.
0
 
LVL 5

Accepted Solution

by:
palanee83 earned 2000 total points
ID: 24156736
Hi,

Yes its possible to run the java script which is available in the remote server  from PHP. But the content of remote URL should be printed before calling javascript function either using fopen() or file_get_content()

ex:
<?php
echo file_get_content("http://www.example.com");
 ?>

If the remote script is is having only JS code then u can directly use  URL in the  'SRC'  attribute of script tag to load the JS function in to the current scope.

<script src="http://www.example.com" > </src>




0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question