javascript - remove div of page loaded in an iframe - Stack Overflow

I'm pletely new to javascript and need some assistance. I need to remove a div element from anothe

I'm pletely new to javascript and need some assistance. I need to remove a div element from another page which is shown on mine through an <iframe>.

This is my page's code

<html>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <head>
    <script language="javascript">
    </script>
        <title>TITLE</title>
        <style type="text/css">
            body, html
            {
                margin: 0; padding: 0; height: 100%; overflow: hidden;
            }

            #content
            {
                position:absolute; left: 0; right: 0; bottom: 0; top: 0px; 
            }
        </style>
    </head>
    <body>
        <div id="content">
            <iframe width="100%" height="100%" frameborder="0" src="PAGE HERE"/>
        </div>
    </body>
</html>

I need to remove this Div element of another webpage

<div p="removepls">

EDIT

CANNOT EDIT EXTERNAL WEBSITES WHICH ARE NOT HOSTED ON YOUR SERVER

I'm pletely new to javascript and need some assistance. I need to remove a div element from another page which is shown on mine through an <iframe>.

This is my page's code

<html>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <head>
    <script language="javascript">
    </script>
        <title>TITLE</title>
        <style type="text/css">
            body, html
            {
                margin: 0; padding: 0; height: 100%; overflow: hidden;
            }

            #content
            {
                position:absolute; left: 0; right: 0; bottom: 0; top: 0px; 
            }
        </style>
    </head>
    <body>
        <div id="content">
            <iframe width="100%" height="100%" frameborder="0" src="PAGE HERE"/>
        </div>
    </body>
</html>

I need to remove this Div element of another webpage

<div p="removepls">

EDIT

CANNOT EDIT EXTERNAL WEBSITES WHICH ARE NOT HOSTED ON YOUR SERVER

Share Improve this question edited Apr 4, 2014 at 19:44 user3499401 asked Apr 4, 2014 at 19:10 user3499401user3499401 431 gold badge1 silver badge4 bronze badges 1
  • is that 'other page' ing from the same domain as your page? If not, you can't manipulate the contents of it. – DA. Commented Apr 4, 2014 at 19:27
Add a ment  | 

2 Answers 2

Reset to default 3

If the src of the iframe is not from the same domain and using the same protocol as the page it is rendered in, then you will not be able to access that content. This violates the same-origin policy and is a security feature in all modern browsers. If the iframe contains a page you created with the same domain and protocol, then you can query for the iframe with jQuery just like any other DOM element: $('iframe') or you could also give the iframe a class or ID and query for it that way.

$('iframe').contents().find("div[p='removepls']").remove();

That should find and remove the oddly attributed div.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744191827a4562468.html

相关推荐

  • javascript - remove div of page loaded in an iframe - Stack Overflow

    I'm pletely new to javascript and need some assistance. I need to remove a div element from anothe

    8天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信