SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery - change html attr in iframe is that possible?

    can i change the html dir attr inside an iframe after its loaded?
    i tried doing it this way:
    Code:
     $('#iframeid html').attr('dir','ltr');
    but it didnt work...

  2. #2
    SitePoint Enthusiast Anthony.Barnes's Avatar
    Join Date
    Aug 2011
    Location
    Canberra, Australia
    Posts
    80
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't manipulate the HTML of an iframe if the content is not from the same domain, this is prevented by the browser in order to counter cross site scripting. That would be the first place I'd look. The second is changing up your jQuery selection slightly:

    Code:
    var $html = jQuery('iframe').contents().find('html');
    $html.attr('dir','ltr');
    I can't recall why this works off the top of my head, just that it does.


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
  •