/    Sign up×
Community /Pin to ProfileBookmark

Editing an IFrame with Javascript

I am referencing an iframe from another server in my website. The iframe is in a table format, and I want to get rid of the top two rows of the table for my website.

Is there any way I could display the iframe without the first two rows?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@MrRedOct 11.2010 — If the other server is effectively the same domain it should be possible. If not, not.

On my geographical filter page I load an IFRAME 4 times and inspect for a given parameter, extract the whole of the <TR> if it agrees and stitch together 4 tables of results.

I have had a frustrating few months figuring which of the various way to get at the text but finding the IFRAME by id (getElementByID) and then getting the rows by TAG (getElementsByTag - I think).

But there were several blind allies to the best pointer. innerHTML works on some, document.body.firstChild etc - I use FireFox and FireBug to find the pointers. I am sure there is a logic and syntax to the pointers but not in my head!

If you need help try looking at my code at http://www.users.waitrose.com/~cresby/fcctest3.htm but there are 800 lines just in the main file (.js). Best of luck. (I am not at my computer right now).
Copy linkTweet thisAlerts:
@rnd_meOct 13.2010 — use something LIKE:

[CODE]
var iframe=document.getElementById("iframe1);
[].slice.call(iframe.contentWindow.document.getElementsByTagName("tr")).map(function(a,b){
if(b<3){a.style.display='none'; }
});
[/CODE]
×

Success!

Help @Draksis314 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.15,
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,
)...