Jump to content

Recommended Posts

OK, I know this aint PHP, but I don't know where else to go, and I am sure I am missing something stupidly simple here...

 

Look at the following code, logically it should work perfectly fine...

 

<form target="editor" onsubmit="this.action=this.goTo.value">
<input type="text" name="goTo">
<input type="submit" name="submit" value="submit">
</form>
<a target="editor" href="javascript:document.body.contentEditable='true'; document.designMode='on'; void 0">edit</a>
<iframe src="" id="editor" name="editor" border="0" frameborder="0" width="100%" height="500"></iframe>

 

But it doesn't! Any ideas?

 

I am trying to let a user enter their desired URL, which then loads in the iframe. That works fine, but then when I try to let them edit it with the link, it failes. Using the direct javascript on the parent page works fine, so why not in the target="editor" ?

Link to comment
https://forums.phpfreaks.com/topic/151572-simple-script-please-advise-me/
Share on other sites

Hmm, and I am under the illusion that these forums are here to distribute knowledge and support between its members... These are "support" forums not "snide" forums, and pardon me for pointing out the obvious but out of the two the post you submitted was far from support! That, to me, doesn't sound logical!

You know its not PHP yet you posted here!

doesn't sounds logical!

 

Hmm, and I am under the illusion that these forums are here to distribute knowledge and support between its members... These are "support" forums not "snide" forums, and pardon me for pointing out the obvious but out of the two the post you submitted was far from support! That, to me, doesn't sound logical!

MadTechie commented that because you posted your thread under "PHP help" Instead of "Javascript Help". If you know you want javascript help it should be logically posted under Javascript.

 

What exactly is error you recieve.

And is there any reason not to use php for this? Simply using a php form to post values would be easier.

If you do want to go the javascript you'll have to prevent the form from getting submitted and only refresh part of the Page.

I am a real coding rookie, and this is one of my first unique ideas which I actually am trying to build... The idea is to allow a user to enter a URL of their desired page, then once loaded (in the iframe) they can edit it in their browser. It's only a toy, but I think it would be cool.

 

I am not exactly receiving errors, It just simply dont work. I have not tried it on my server yet, as with it being JS/HTML, it should work perfectly fine client-side. The page loads perfectly fine in the iframe, but when you click "edit" nothing happens.

 

And yeah I agree, I shouldn't have posted in a PHP Section, I just wasn't aware of any HTML section, I found that just now.

 

If there is a PHP Method of doing this, it would be much better in terms of compatibility and security, as it is a slight pain allowing users to View Source and take my code.

 

Thanks in advance for any help offered :)

Hmm, and I am under the illusion that these forums are here to distribute knowledge and support between its members... These are "support" forums not "snide" forums, and pardon me for pointing out the obvious but out of the two the post you submitted was far from support! That, to me, doesn't sound logical!

 

Using your own logic you might as well post the same question in any support section of any site!

however your probably notice that all these site (including this one) have rules.

 

Pick the right forum for your question. If you have a Database-only question' date=' post in the database section (MySQL/etc). If you have an OOP question, post in the OOP board. If your question doesn't relate to programming, post in the Misc board. We've also turned off polls in most boards. If you have a question that requires a poll, post it in the Polls board.[/quote']

 

Why do we have these rules, you may ask?

Well its to make life easier,

for members to find related problems and

so other members who know that subject to be able to help.

The idea is to allow a user to enter a URL of their desired page, then once loaded (in the iframe) they can edit it in their browser. It's only a toy, but I think it would be cool.

 

That does sound similar to what greasemonkey for firefox does though.

as for loading an url into an iframe using only php you could use:

<form action="form_name_here.php" method="post">
<input type="text" name="url" />
<input type="submit" name="submit" value="submit" />
</form>
<?php
if(isset($_POST['submit']) && $_POST['url']!=""){
echo("<iframe src=\"{$_POST['url']}\"></iframe>");
}
?>

it's not tested btw

 

If you are going to use something like that it's very likely that you are going to run into crosssite scripting issues.

Fixed your script was missing semi colons:

<form target="editor" onsubmit="this.action=this.goTo.value;">
<input type="text" name="goTo">
<input type="submit" name="submit" value="submit">
</form>
<a target="editor" href="javascript:document.body.contentEditable='true'; document.designMode='on'; void 0;">edit</a>
<iframe src="" id="editor" name="editor" border="0" frameborder="0" width="100%" height="500"></iframe>

Hi darkfreaks.

Yeah I noticed that a lil earlier, but even so, it does not work. Nevermind, I have given up on the code anyway, it was only ever a toy, and I have more important things to worry about than this. Maybe when I am bored outta my head with nothing better to do, I will try again.

 

Thanks to everyone here who tried to help, I am grateful for that.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.