Wednesday, August 11, 2010

How to pass HTML in query string using php?

I want to pass an element through query string using php, I have tried urlencode(), htmlspecialchars() but without any success. I do not know what I'm doing wrong. Or is this even possible?How to pass HTML in query string using php?
That sounds similar to the solution I came up with to display examples on my html tags guide website.

On my website people can modify html code in a textarea. On activating the Refresh button the content of the textarea is passed through the javascript escape() function and passed to a specially written page (show.html) displayed in an %26lt;iframe%26gt;. The show.html page has javascript that takes the query string, passes it through the javascript unescape() function and displayes it.

The show.html page is really simple:



%26lt;title%26gt;Show ';page'; passed as parameter%26lt;/title%26gt;

%26lt;meta name=';robots'; content=';noindex, nofollow';%26gt;

%26lt;script type=';text/javascript';%26gt;

function showpage() {

var queryString = window.location.href;

queryString = unescape( queryString.substr( queryString.indexOf( ';?'; ) +1 ) );;

document.write( queryString );






%26lt;script type=';text/javascript';%26gt;





For an example of this in use see:鈥?/a> and look at the source for the page.How to pass HTML in query string using php?
From my point of view, there are two things you might be trying to do.

First of all, if you are trying to embed a page from a URL in an iframe, use this code:

But what I think you're really trying to do, is to have stored in a variable show up in that iframe, without using any URLs. This is supported on most browsers (except IE) using the data: protocol.

First of all, you would have to know the MIME type of the data you are trying to send. For HTML documents that's ';text/html';.

Then you would have to use this code:

What this does is passing the HTML document through the URL in the iframe.
You can use javascript within a php file using the %26lt;script%26gt; tag

You can pass HTML in query string using id.location= ( urpage.php?';%26lt;iframe%26gt;..%26lt;/iframe%26gt;'; }

Im not sure if it will work , but u can give it a try..
Why you are passing iframe? You need to explain it. Well, you don't need to pass iframe. You can just pass a URL instead and use urlencode?

No comments:

Post a Comment