0

I have the code below in a .php file on my site. I would like to be able to type the link to the .php file in the address bar, and for the php script to run on the current page. How could I do this? PHP File:

<SCRIPT language=JavaScript>
javascript:document.body.contentEditable='true'; document.designMode='on';void(0)
</script>
7
  • That's hardly possible due to the Same Origin Policy. Why not copy+paste the Javascript command into the address bar instead? Commented Jan 14, 2011 at 0:32
  • because I am going to use this in an iPhone app, as the code will not run in a UIWebView Commented Jan 14, 2011 at 0:32
  • is the refering page not editable by you? Commented Jan 14, 2011 at 0:33
  • 1
    Im sure it can be done that way, I don't know much about web development myself... Commented Jan 14, 2011 at 0:38
  • 1
    @XcodeDev: If you type address of the PHP file in the address field, then you are opening this page. You are navigating away from the current page and the "new page" will show nothing as you only output JavaScript. You cannot type another URL in the adress bar and stay at the same page. Commented Jan 14, 2011 at 1:29

1 Answer 1

0

The way you suggest to do it it's not possible, but you can have a "bookmarlet" which is javascript code that you drag and drop to your bookmarks bar, and every time you click on it, it runs a script.

Try it here: http://jsfiddle.net/XtHsP/

1
  • I could do that, but I will be implementing this in an iPhone app, that is why I would like to use php. If I enter the javascript code into the iphone addr bar, it will not work. Commented Jan 14, 2011 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.