Link to home
Start Free TrialLog in
Avatar of xenium
xenium

asked on

Displaying a simple HTML page from input embedded into a URL (part IV)

hi,
I'm looking to display very simple web pages from HTML contained within a URL, for example:

To display a webpage comprising the following HTML...

<a href="https://www.google.com/search?&q=apples">Click for apples</a>
<BR>
<a href="https://www.bing.com/search?&q=oranges">Or for oranges</a>

Open in new window


...the HTML would be included in a URL that points to a script that will display it, eg

www.mydomain.com/myscript.html?input=%3Ca%20href%3D%22https%3A%2F%2Fwww.google.com%2Fsearch%3F%26q%3Dapples%22%3EClick%20for%20apples%3C%2Fa%3E%0A%3CBR%3E%0A%3Ca%20href%3D%22https%3A%2F%2Fwww.bing.com%2Fsearch%3F%26q%3Doranges%22%3EOr%20for%20oranges%3C%2Fa%3E%0A

Open in new window


I'm not sure if the encoding is necessary, ideally if not i would avoid it in which case the URL would be:

www.mydomain.com/myscript.html?input=<a href="https://www.google.com/search?&q=apples">Click for apples</a><BR><a href="https://www.bing.com/search?&q=oranges">Or for oranges</a>

Open in new window


I need the script for myscript.html

This is a generic version of this question: https://www.experts-exchange.com/questions/29086043/Displaying-a-simple-HTML-page-from-input-embedded-into-a-URL.html

Many thanks

Acknowledgement:
Encoding by https://meyerweb.com/eric/tools/dencoder/
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

to put as URL (query string) with HTML codes, you wil need to encode the content.

or else try to accept by adapting post data instead.

but no matter what, it would be better to verify what was being passed to your script before you process and display it, for security purposes.
no you don't have to encode it. it works just as advertised.
http://ee2908660720180228074457.azurewebsites.net/
The encoding is not necessary it was originally suggested due to the fact that characters that are valid in URL's were being used and it was a way to ensure that delimiting characters were not misinterpreted.

With the delimiters chosen you should be fine using the non encoded version.
Avatar of xenium
xenium

ASKER

hi Julian,

Thanks again.

The script i need in this question is probably simpler than the ones before. In this general case the HTML is created before submitting it to the URL (rather than have the javascript create it) so then the javascript simply displays the HTML. This HTML could be anything (within any length limits imposed by the browser) and could for example just display a note with a picture for example.

It's probably a trivial operation in javascript, but my knowledge here is zero!

Thanks again for your help.

Alex
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xenium

ASKER

Thanks again that works fine.
Avatar of xenium

ASKER

Only on bluehost do i get the following error, any ideas?

Not Acceptable!
An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.

Update: a quick google suggests i need to update my htaccess file.

Here is a separate question on the issue.