|
Post by eveready on May 28, 2010 5:47:18 GMT -8
|
|
|
Post by rhondairv on May 28, 2010 13:43:37 GMT -8
This is a COOL idea!!!
|
|
|
Post by Wormopolis on May 28, 2010 17:56:24 GMT -8
you have to be careful with doing innerHTML replacements when it doesnt actually call for it. what I would do is a match command on the innerHTML first: if aTD .innerHTML.match(/\[frame\](.*?)\[\/frame\]/)) {
}
that will check to see if its even in the post to begin with. fi it isnt, it goes ahead and moves on.
now by doing the match, we have access to a RegExp variable called $1 which is whatever it finds inside the (.*?) between the [frame] [/frame] end pieces.
content=RegExp.$1;
content will end up being the URL of the iFrame you are trying to construct.
next you would make a variable that contained all the new HTML as one complete line:
nwStuff='<iFrame width="100%" height="500px" scrolling="no" src ="' + content + '"></iFrame>';
THEN do the replace as one complete line instead of breaking it up into parts:
aTD.innerHTML=aTD.innerHTML.replace(/\[frame\](.*?)\[\/frame\]/,nwStuff);
now of course, the way we have done it, it is going to see the first instance of a frame tag, replace it, then move on to the next cell. well if we want to make sure that there arent anymore frame tags in the SAME cell, we can adjust the loop variable "a" by subtracting 1 from it. The loop will start from the same cell again. if it finds another frame tag, it repeats the replacement, if not, THEN it moves on.
so we have it as:
if aTD.innerHTML.match(/\[frame\](.*?)\[\/frame\]/)) { content=RegExp.$1; nwStuff='<iFrame width="100%" height="500px" scrolling="no" src ="' + content + '"></iFrame>'; aTD.innerHTML=aTD.innerHTML.replace(/\[frame\](.*?)\[\/frame\]/,nwStuff); a--; // this subtracts 1 }
by putting that if statement inside the existing if statement (the one where you checked the attributes of the aTD cell), it should be able to keep replacing all the frame tag it finds.
|
|
|
Post by eveready on May 28, 2010 19:10:34 GMT -8
|
|
|
Post by Wormopolis on May 28, 2010 19:36:52 GMT -8
no.. I was falling asleep at the keyboard during that entire post. I just now woke back up.
so I apparently missed it while retyping
|
|
|
Post by eveready on May 28, 2010 21:27:26 GMT -8
Been there, done that. Thanks again.
|
|
|
Post by Wormopolis on May 30, 2010 17:13:37 GMT -8
Good work!
Its a code that is worth submitting as well if you want to make it public.
|
|
|
Post by rhondairv on Jun 1, 2010 14:50:09 GMT -8
Is there a way so that this frames all posts are framed with an image or color? Such as default.
|
|
|
Post by Wormopolis on Jun 1, 2010 15:20:26 GMT -8
iFrames take on the HTML of whatever the source has for a background.
|
|