/    Sign up×
Community /Pin to ProfileBookmark

passing values between frames -> parsing error

Hello

I have a window call A.html that contains an iframe called B.php

B.php determines what its content should be in HTML and it holds that info in a PHP variable called $content

That means that the value of $content is now something like:

[code]
<table border=”2″ cellspacing=”0″ width=”100%”>
<tr>
<td>
<span style=”font-family: ‘Arial, Helvetica, sans-serif’>Hello</span>
</td>
</tr>
</table>
[/code]

Note that the code contains both ” and ‘

Now in the iframe onload event I want to pass the content of the $content variable to the innerHTML value of some div in A.html

I do the following:

[code=php]
function onLoad() {
var divElement = parent.document.getElementById(‘div’);
divElement.innerHTML = ‘<?php print $content; ?>’;
}
[/code]

Now note that the single ‘ that enclouses the value of the innerHTML. They interfere with the ‘ and ” that are part of the content of $content

How can I solve this problem and pass any arbitrary HTML content between pages by using JavaScript?

regards
Help would be appreciated

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 10.2004 — Not sure (not a JavaScript guru), but how about trying:
[code=php]
function onLoad() {
var divElement = parent.document.getElementById('div');
divElement.innerHTML = '<?php print addslashes($content); ?>';
}
[/code]
Copy linkTweet thisAlerts:
@jasongrauthorNov 11.2004 — I solved it by escaping ' with

and replacing all rn with ' '

all t with ' '

and all n with ' '
Copy linkTweet thisAlerts:
@jinkasNov 11.2004 — [i]Originally posted by jasongr [/i]

[B]I solved it by ...[/b][/QUOTE]


dude, [b][i]you[/i][/b] didn't solve it...a few of us over at sitepoint gave you the answer

and make sure your css is correct by not using single-quotes inside of style definitions

ie.
<i>
</i>style="font-family: serif;"
×

Success!

Help @jasongr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...