SitePoint Sponsor

User Tag List

Results 1 to 11 of 11

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    iframe same domain diff sub domain

    I think I have read that this is possible.

    The situation is that I have a page(index.htm) on say: content.mydomain.corp
    This page submits a form to: work.mydomain.corp

    The result is targeted(from the form on index.htm) to an iframe(named "myIframe") on index.htm

    This loads the result fine, but when I try to access the iframe with javascript from index.html, I get an access denied error.

    I am trying to access it with
    self.myIframe.document.documentElement.innerHTML

    I've tried using:
    document.domain = "mydomain.corp";

    at the top if index.html to no avail.

    Any help, or links to help would be greatly appreciated.

    Thanks!

    M=

  2. #2
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the problem is going from one server to another. That's what it doesn't like. This is a security feature and I've had similar problems myself when sites have been masked in a frameset and I've wanted to do JavaScript stuff. We never resolved it. Ended up telling the client that if they wanted the functionality requiring that, they'd have to sort out their hosting properly and stop masking the URL.

    I know that doesn't help you much... sorry.

  3. #3
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What if I directed the content to a regualar frame. Would that make a difference?

  4. #4
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mikehd5
    What if I directed the content to a regualar frame. Would that make a difference?
    Unfortunately, this security feature applies to all kinds of frames. Not just iFrames. Moving to a normal frame won't help.

    How about passing the data in a querystring? If that's possible, it should work, because all you're asking the browser to do is open a URL. Not pass any encoded data "behind the scenes" as it were...

    Edit:

    Which I've just realised is exactly what Markdidj was saying. His code is building a querystring for you:
    yourfile.html?field1=value1&field2=value2&field3=value3....etc.!


    G

  5. #5
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you could send info within the URL to another iframe with
    Code:
    <a href="http://site.co.uk/formOutput.html" onclick=function() { this.href+="?"+document.myForm.FirstValue.value+"&"+document.myForm.secondValue.value }
    target="newFrame">
    which can also be applied onsubmit.

    How about sharing JS files? you can read js from other sites, so you could create js files using perl or php from the form, then when the new location comes in it reads the js from the other site
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  6. #6
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe I am not understanding you Markdidj.

    But I have need what the exe sends to the target of the form like this:


    document.write("<form name='myForm' action=" + pageGeneratedAction + " method='post' target='myIframe' ENCTYPE = 'application/x-www-form-urlencoded' >");

    There is javascript that generated the "pageGeneratedAction" variable(which targets an exe on the server), then the form is submitted to iframe. I then parse that to get the info I need and load the users preferences.

    I don't need the original value of the form I need the info that is returned by the exe.

    M=

  7. #7
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I am missing something here...

    I cannot change the way the data is sent back from the server after the form is submitted. All I can do is try and control where the data from the server gets targeted to.

    I am not that savvy with forms so maybe I am not seeing this correctly, but passing the forms values in a string doesn't change the way the data will be sent back. Right?

    If I am missing something and it is possible to 'catch' the data returned as a string that would be awesome, but I can't 'see' how to do it. Maybe I am not looking in the right place?

    Thanks

  8. #8
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmmm... we may be barking up the wrong tree here, in which case, I apologise. But what do you mean by "access the iframe with javascript from index.html"? What exactly are you trying to do?

    It's just occurred to me that I may have assumed you were having a different problem to the one you have. Just need to clarify.


  9. #9
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Is it security info? if it's not you could write an external js or XML doc from the exe file, which can be read from any domain.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  10. #10
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The thing is the exe is part of a LMS (learning management system) and I can't change what the exe does. It will always spit out the data formated in the same way.

    It links to a subDomain with the content.

    I got around this problem by having the content page that the LMS linked to redirect itself to a page on the LMS server sending all the relavent info. This page parses out what I need, including the content http location, then lauches the content. Good.

    Now my content cannot submit a form to the other subdomain. Is this the same deal? no cross sub domians?

    M=

  11. #11
    SitePoint Member
    Join Date
    May 2003
    Location
    here
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I got it working now, the submission problem was an error in on the values.

    Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •