InterOcean Designs
« PopUp Content »

Welcome Guest. Please Login or Register.
May 19, 2013, 4:54am




InterOcean Designs :: ProBoards Codes :: ProBoard Code Database :: PopUp Content
Page 1 of 2 » Jump to page   Go    [Search This Thread] [Share Topic] [Print]
 AuthorTopic: PopUp Content (Read 1,427 times)
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 PopUp Content
« Thread Started on Jul 1, 2011, 3:01am »

PopUp Content by SubDevo
Tested in IE, FF, Opera, Safari and Chrome.

I already have a code for a popup music player and did a request for a popup chat.
I decided to make one code that allows you to use ANY HTML for the popup window.
This means any chatbox, music player or video embed codes. Or anything else that you want in the window. Each popup window that you create is completely customizable using CSS. That means each of your windows can have a different background color or image and more!

Enjoy!!! :)
SubDevo

Instructions:

You need two other items besides the code.
First you need to put this somewhere in your forum. It does not matter where.
Best to keep it just above the code so you can easily find it.

<div id="popupContent" style="display:none;">
ANY HTML CONTENT HERE
</div>


Replace the Yellow with your HTML content. Embed codes, HTML etc...
The ID is used in your link to launch the popup.

Second, you need a link to launch the popup. This could be a text or image link.
Just use javascript:popupStuff('ELEMENT ID', 'TITLE', WIDTH, HEIGHT) as the href of the link.
Note the use of single quotes (apostrophes) around the ID and TITLE.

Example:

<a href="javascript:popupStuff('popupContent', 'Our Chat!', 250, 500)">Launch our Forum Chat!</a>

In the above, it will launch a popup window containing the HTML from the element "popupContent".
The title of the window will be "Our Chat!" and it will be 250px wide by 500px high.

You may have multiple popups if you wish. Just copy/paste the div (above) changing the ID and the contents of it. Use the ID in the href of the link and also set the width and height values.
Make sure any ID's used are unique. Do not use the same name.

Please Read!
In order to use CSS (style your popup background etc..) and scripts or embed codes, you must do the following! Put <!-- before any styles and scripts and put a --> below the last script or style tag. These are standard HTML remarks. Your browser will now ignore everything in between these two remarks and those scripts will not load with every page load of your forum. This also ensures that any script or CSS you use will work in your popup for every major browser. There cannot be any other HTML remarks in the scripts or CSS that you use. So, don't use them and remove them if they are in the codes or CSS. The only two remarks should be the ones you added at the beginning and end as instructed.

Example:

The Yellow remarks are good. The Red remarks are bad and must be removed.
The green line is where you would put your background color for that individual popup.
To use an image change that line to: body {background-image: url(IMAGE URL);}

<div id="popupContent" style="display:none;">
<!--
<style type="text/css">
<!--
body {background-color: #FF0000;}
-->
</style>

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
SOME RANDOM CHAT BOX EMBED CODE HERE
</object>

<script type="text/javascript">
<!--
alert("woohoo!");
-->
</script>
-->
</div>


Of course, you can do more that just change the background color or image. You may use any CSS that you could use on your forum to change the links color, font sizes and styles etc...
Just ask if you need help with these. ;)

Nothing else to edit in the code!

Location: Global Header or Footer
Code:
<script type="text/javascript">
/* PopUp Content by SubDevo */
/* v1.01 Global Header or Footer - Leave this header intact. Do not repost. */
/* [url]http://interoceandesigns.com[/url] or [url]http://lsdp.proboards.com[/url] */

function popupStuff(a,n,w,h){
&nbsp; &nbsp;var b=document.getElementById(a),html,mC;
&nbsp; &nbsp;if(b){ b=b.innerHTML.replace(/<!--|-->/g,"");
&nbsp; &nbsp;&nbsp; &nbsp;html='<html><head><title>'+n+'</title></head><body><div style="width: '+w+'px;">'+b+"</div></body></html>";
&nbsp; &nbsp;&nbsp; &nbsp;mC=window.open('',a,'width='+(w+40)+',height='+(h+30)+',top=0,left=0,scrollbars=yes, resizable=yes');
&nbsp; &nbsp;&nbsp; &nbsp;mC.focus(); with(mC.document){open(); write(html); close();}
}}
</script>


CODE EDIT (4/08/2012):
Code updated to allow the use of any CSS and scripts within the popup divs. Better cross browser compatibility and the code actually became smaller as a result. ;)
« Last Edit: May 1, 2012, 6:58am by SubDevo »Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
aRMY83
Elite Member
IOD Supporter
member is offline

[avatar]

It's me!


[homepage]

Joined: Mar 2010
Gender: Male
Posts: 1,077
Location: Just a Stone's Throw Away!
Karma: 40
 Re: PopUp Content
« Reply #1 on Jul 2, 2011, 10:00am »

SubDevo...

Am I to understand that if one has a chat room and music player, as I have, which loads in separate windows, that if I implement this code, that both will be in one window?
Link to Post - Back to Top  IP: Logged

[image]

[image]
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 Re: PopUp Content
« Reply #2 on Jul 2, 2011, 10:02am »

Ummm. Nope. Keep what you have. This is a one use code. Dang, I don't know why I didn't think of that.
I'll work on this to make it for multiple popups. I'll keep ya posted...
Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
aRMY83
Elite Member
IOD Supporter
member is offline

[avatar]

It's me!


[homepage]

Joined: Mar 2010
Gender: Male
Posts: 1,077
Location: Just a Stone's Throw Away!
Karma: 40
 Re: PopUp Content
« Reply #3 on Jul 2, 2011, 10:42am »

Thanks SubDevo...
Link to Post - Back to Top  IP: Logged

[image]

[image]
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 Re: PopUp Content
« Reply #4 on Jul 5, 2011, 4:42pm »

Ok, aRMY83. Since you demanded it! lol
The code has been updated to support multiple popup windows with different content! 8-)
And believe it or not, but the updated code is actually smaller than before!
Make sure you read the instructions for the changes.
« Last Edit: Jul 5, 2011, 7:00pm by SubDevo »Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
aRMY83
Elite Member
IOD Supporter
member is offline

[avatar]

It's me!


[homepage]

Joined: Mar 2010
Gender: Male
Posts: 1,077
Location: Just a Stone's Throw Away!
Karma: 40
 Re: PopUp Content
« Reply #5 on Jul 5, 2011, 8:59pm »

Nice SubDevo and I mean real NICE! Everything working just fine with the exception of this part, that I can't seem to get it to work:

Here's what I have in the Main Footer right now: ( test site )


Code:
<a title="Click to Launch our Forum Chat!" href="javascript:popupStuff('popupChat', 720, 362)"> <img border="0" src="http://i1043.photobucket.com/albums/b436/army83_2010/Army83-ForumChat.png" /></a><a title="Click to Launch our Forum Chat!" href="javascript:popupStuff('popupMusic', 280, 360)"><img src="http://i1043.photobucket.com/albums/b436/army83_2010/Army83-MusicPlayer.png" border="0" alt="PopUp Music Player!" /></a>


and I need to add the chat rules alert:

Code:
href="javascript:alert(' Rules for our Chat!\n\n* English only! Anything else will be deleted.\n* Absolutely, positively NO profanity allowed!\n* NO pornographics of any kind!.\n* NO advertising allowed.\n* Please refrain from using all CAPS.\n* Be friendly. Be polite. Be considerate.\n* Chat Rules are subject to change without notice! \n\n Enjoy and happy chatting!'); popupChat()">


By the way, since I demanded it, where is the "Close Chat or Close Player" at the bottom of those windows... ;)
Link to Post - Back to Top  IP: Logged

[image]

[image]
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 Re: PopUp Content
« Reply #6 on Jul 5, 2011, 9:44pm »

This should do it...
Code:
<a title="Click to Launch our Forum Chat!" href="javascript:alert(' Rules for our Chat!\n\n* English only! Anything else will be deleted.\n* Absolutely, positively NO profanity allowed!\n* NO pornographics of any kind!.\n* NO advertising allowed.\n* Please refrain from using all CAPS.\n* Be friendly. Be polite. Be considerate.\n* Chat Rules are subject to change without notice! \n\n Enjoy and happy chatting!'); popupStuff('popupChat', 720, 362)"> <img border="0" src="http://i1043.photobucket.com/albums/b436/army83_2010/Army83-ForumChat.png" /></a><a title="Click to Launch our Forum Chat!" href="javascript:popupStuff('popupMusic', 280, 360)"><img src="http://i1043.photobucket.com/albums/b436/army83_2010/Army83-MusicPlayer.png" border="0" alt="PopUp Music Player!" /></a>

After thinking about it, I thought it was unnecessary since you can just close the window like any other window. So, I removed the "Close window" link from the code...
Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
aRMY83
Elite Member
IOD Supporter
member is offline

[avatar]

It's me!


[homepage]

Joined: Mar 2010
Gender: Male
Posts: 1,077
Location: Just a Stone's Throw Away!
Karma: 40
 Re: PopUp Content
« Reply #7 on Jul 5, 2011, 10:21pm »

Working like a charm now SubDevo and my hat is off to you my friend!


Quote:
After thinking about it, I thought it was unnecessary since you can just close the window like any other window. So, I removed the "Close window" link from the code...


Agree! and here's to you [image] for your excellent coding and assistance to everyone.
Link to Post - Back to Top  IP: Logged

[image]

[image]
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 Re: PopUp Content
« Reply #8 on Jul 5, 2011, 10:59pm »

Ahh, thanks for the beer! lol Maybe, I should change the code so you can put your own title for each popup window. I noticed both of yours say "chat". What do you think?
Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
aRMY83
Elite Member
IOD Supporter
member is offline

[avatar]

It's me!


[homepage]

Joined: Mar 2010
Gender: Male
Posts: 1,077
Location: Just a Stone's Throw Away!
Karma: 40
 Re: PopUp Content
« Reply #9 on Jul 6, 2011, 5:52am »

WOW! as I never noticed that:

var popcTitle="Our Forum Chat!"; // Title of Popup window

Would look strange to the user if they clicked on the Music Player and the window showed "Our Forum Chat!. lol

Awaiting for the change... ;)




Link to Post - Back to Top  IP: Logged

[image]

[image]
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 Re: PopUp Content
« Reply #10 on Jul 6, 2011, 9:47am »

Done! Now, you can specify the title in the link. Code has changed, of course.
Only the one variable now for the style of all popups.
Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
aRMY83
Elite Member
IOD Supporter
member is offline

[avatar]

It's me!


[homepage]

Joined: Mar 2010
Gender: Male
Posts: 1,077
Location: Just a Stone's Throw Away!
Karma: 40
 Re: PopUp Content
« Reply #11 on Jul 6, 2011, 10:25am »

Got it SubDevo and damn that code is getting smaller. lol

p.s. I even cut some stuff out of the "link to launch the popup" which now reads:

Code:
<center><a title="Click to Launch our Forum Chat!" href="javascript:alert(' Rules for our Chat!\n\n* English only! Anything else will be deleted.\n* Absolutely, positively NO profanity allowed!\n* NO pornographics of any kind!.\n* NO advertising allowed.\n* Please refrain from using all CAPS.\n* Be friendly. Be polite. Be considerate.\n* Chat Rules are subject to change without notice! \n\n Enjoy and happy chatting!'); popupStuff('popupChat', 'Our Forum Chat!', 720, 362)"> <img border="0" src="http://i1043.photobucket.com/albums/b436/army83_2010/Army83-ForumChat.png" /></a><a title="Click to Launch our Music Player!" href="javascript:popupStuff('popupMusic', 'Our Music Player!', 280, 360)"><img border="0" src="http://i1043.photobucket.com/albums/b436/army83_2010/Army83-MusicPlayer.png" /></a></center>


As the Army says, "lean, green, Army fighting machine" ;)

Thanks for everything my friend!
Link to Post - Back to Top  IP: Logged

[image]

[image]
LunyRed
Senior Member
member is offline

[avatar]


[homepage]

Joined: Sept 2009
Gender: Male
Posts: 542
Location: An archipelago in SE Asia
Karma: 14
 Re: PopUp Content
« Reply #12 on Aug 4, 2011, 8:03pm »

I have a music player in my site. I've been wondering....

If I apply this code for our music player, does that mean....the forum's loading time won't be affected by the music player that fetches the songs/video from an external site like YouTube?

Sounds like this is the code I need for my MixPod... :o
Link to Post - Back to Top  IP: Logged

[image]
[ME] and I are best buddies~ Unlike me, [ME] is obsessed with Justin Bieber.. o_o'
SubDevo
Co-Admin
Code Support
member is offline

[avatar]

Creator of LSD...


[homepage]

Joined: Mar 2009
Gender: Male
Posts: 2,594
Location: MI, USA
Karma: 102
 Re: PopUp Content
« Reply #13 on Aug 5, 2011, 10:26pm »


Aug 4, 2011, 8:03pm, LunyRed wrote:
If I apply this code for our music player, does that mean....the forum's loading time won't be affected by the music player that fetches the songs/video from an external site like YouTube?

That is correct Luny. Only the link to the popup would load when your site loads.
The player code will not run until a user clicks the link for the popup. Nice thing is that the popup is there even if you close you browser and the music will not stop and start between page loads. A better user experience IMO.
« Last Edit: Aug 5, 2011, 10:26pm by SubDevo »Link to Post - Back to Top  IP: Logged

[image] [image]
[image]
Why are you looking at my signature, [ME]?
LunyRed
Senior Member
member is offline

[avatar]


[homepage]

Joined: Sept 2009
Gender: Male
Posts: 542
Location: An archipelago in SE Asia
Karma: 14
 Re: PopUp Content
« Reply #14 on Aug 7, 2011, 9:47pm »


Aug 5, 2011, 10:26pm, SubDevo wrote:
That is correct Luny. Only the link to the popup would load when your site loads.
The player code will not run until a user clicks the link for the popup. Nice thing is that the popup is there even if you close you browser and the music will not stop and start between page loads. A better user experience IMO.

This is indeed amazing! Truly a wonderful and brilliant code, Sub! =D I'm currently using this now in my forum. Works like a charm~ :)

Now that we're on topic, I'd like to ask something minor regarding the code. If I want a background image for the popup, the variable should be like this then?

var popcStyle="background: url(IMAGE URL)"; // Background color and image.

Do I have to remove the hex values or choose to keep it? Removed there was the color value of #080808.
Link to Post - Back to Top  IP: Logged

[image]
[ME] and I are best buddies~ Unlike me, [ME] is obsessed with Justin Bieber.. o_o'
Page 1 of 2 » Jump to page   Go    [Search This Thread] [Share Topic] [Print]

Click Here To Make This Board Ad-Free


This Board Hosted For FREE By ProBoards
Get Your Own Free Message Boards & Free Forums!
Terms of Service | Privacy Policy | Notice | FTC Disclosure | Report Abuse | Mobile