PDA

View Full Version : Code to split screen in web browser



rcarruth
09-02-2013, 11:30 PM
I am trying to put some code together that will split a screen into 3 parts, I've borrowed code from a bookmarklet that splits it into 2 frames after getting the URL's from the user.
I've gotten the code to ask for the 3rd frame URL but it won't fill the frame up with the website. The first code listed is the original code:


javascript:ABC=location.href;DEF=prompt('Choose%20File%201',ABC); GHI=prompt('Choose%20File%202',DEF);if(L3f7&&R1Gh7){Fr4Q='<frameset%20rows=\'*,*\'>\n<frame%20src=\''+L3f7+'\'/>';Fr4Q+='<frame%20src=\''+R1Gh7+'\'/>\n';Fr4Q+='</frameset>';with(document){write(Fr4Q);void(close())}}else{void(null)}

Here is the code I've worked on:


javascript:ABC=location.href;DEF=prompt('Choose%20File%201',ABC);GHI=prompt('Choose%20File%202',DEF);JKL=prompt('Choose%20File%203',GHI);if(DEF&&GHI){Fr4Q='<frameset%20rows=\'33%,33%,33%\'>\n<frame%20src=\''+DEF+'\'/>';Fr4Q+='<frame%20src=\''+GHI+'\'/>\n';Fr4Q+='</frameset>';with(document){write(Fr4Q);void(close())}}else{void(null)}

Now the problem so far is when I try to put in some code to declare the frame src for the 3rd frame the whole thing won't work (no prompts appear) Same thing if I try to rename Fr4Q and Fr4Q+. Not being very good with javascript is hurting my ability to debug this properly, any help would be greatly appreciated for I need this for a work project.
Thanks
Bob

jscheuer1
09-03-2013, 03:28 AM
Hmm, what browser(s) are you trying this with?

Many browsers will not allow code like this to run. They either don't understand it, or think it's a security risk.

Opera and Chrome seemed fine with it though. In them:


javascript:
ABC=location.href;
DEF=prompt('Choose File 1',ABC);
GHI=prompt('Choose File 2',DEF);
JKL=prompt('Choose File 3',GHI);
if(DEF&&GHI&&JKL){
Fr4Q='<frameset rows=\'33%,33%,33%\'>\n<frame src=\''+DEF+'\'/>';
Fr4Q+='<frame src=\''+GHI+'\'/>\n';
Fr4Q+='<frame src=\''+JKL+'\'/>\n';
Fr4Q+='</frameset>';
with(document){write(Fr4Q);void(close())}
}else{void(null)}

works fine.

Why would you need to do this anyway? Perhaps there's a better way to achieve what you're after. Does it have to be a bookmarklet?

As a side note, it's not Fr4Q and Fr4Q+, it's just Fr4Q. The operator += means plus equals - the thing = the thing and what follows, basically it means to concatenate.