Jump to content

insert text from iframe.


mikey3521

Recommended Posts

Okey I have a website abc.com, abc.com has an iframe that loads up a plug-in from xyz.com Yes I know Iframes are bad lol moving on. Now that IFRAME content has to pass a var into a text box on abc, so the iframe loads this script which is on abc.com: now this works fine in FF but not IE, any thoughts? When you click it in IE it dosn't pass it to the text input box, it just does nothing, show's no errors..

 

<html>
<head>
<script language="JavaScript" type="text/javascript">
function sendpb() {
parent.parent.insert_text(getParameter(document.location.href, "url"));
};
function getParameter ( queryString, parameterName ) {
var parameterName = parameterName + "=";
if ( queryString.length > 0 )
{
begin = queryString.indexOf ( parameterName );
if ( begin != -1 )
{
begin += parameterName.length;
end = queryString.indexOf ( "&" , begin );
if ( end == -1 )
{
end = queryString.length
}
return unescape ( queryString.substring ( begin, end )
);
}
return "";
}
}
</script>
</head>
<body onload = "sendpb();"></body>
</html>

Link to comment
Share on other sites

Apparently now this is also not working for some FF users.

What I'm trying to accomplish is I am using the Photobucket media plugin on a forum I run. I've embeded it in an IFRAME so when people are making post's they can just log in, select there image and hit add... when they hit "add" it calls the script above and attaches the URL to the image. which then gets inserted into the text box. It workes fine for me and many others. a small percentage of IE & FF users are having difficulties. So now it's not just an IE problem. Is there a better way to write this code.

Link to comment
Share on other sites

I would be surprised if you get it to work in either browser. Most browsers have either a built in or at least updated security patch; that prevents you from cross domaining with an iframe (unless your using a proxy from there website). You could use PHP to get the pages content with file_get_contents() and then do it this way; to get your plugins (maybe).

Link to comment
Share on other sites

Wouldn't this not fall under that category though?

because the IFRAME has xyz.com open but when you click "add" it calls a script on abc.com... so in the end the iframe is abc.com and the site is abc.com... one of the users reported this from the error console.

 

Error: Permission denied to get property Window.insert_text

Source File: http://****.com/photocallback. ... %5B/IMG%5D

Line: 6

 

 

Link to comment
Share on other sites

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.