The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Custom JavaScript for Guests

4 posters

Go down

Solved Custom JavaScript for Guests

Post by collinsexton Mon 10 Jun 2013 - 3:57

Is there a way to have a piece of JavaScript only show for guests who aren't logged in? For example, I have a banner that I want to show only to guests, and be hidden for users who are logged on. The banner is a .swf flash file. My forum link is imtv.forumotion.com. Below is the code I used for the banner.

Code:
<center><embed src="https://dl.dropboxusercontent.com/s/bdlv3w1on44kz0l/bannernow.swf" width="728" height="200" /></center>

I published the code under index_body. Anybody have any suggestions?
collinsexton
collinsexton
Forumember

Male Posts : 88
Reputation : 6
Language : English, Java | HTML | CSS
Location : Indiana

http://imtv.forumotion.com

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by kirk Mon 10 Jun 2013 - 6:25

collinsexton wrote:Is there a way to have a piece of JavaScript only show for guests who aren't logged in? For example, I have a banner that I want to show only to guests, and be hidden for users who are logged on. The banner is a .swf flash file. My forum link is imtv.forumotion.com. Below is the code I used for the banner.


I published the code under index_body. Anybody have any suggestions?

The only way i can think of would be to create a custum widget and have the permissions set for guest only. Since the dimensions are 728 wide, then you may want to have it top center or bottom center in your portal and set portal as your home page? Or you can create a guest forum and have the code in the forums desription, then also have all permissions set for guest only.I guess at the top or bottom would be best for that as well.
kirk
kirk
Forumaster

Male Posts : 11037
Reputation : 653
Language : English,Vulcan,Klingon, Romulan,& Gorn

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by Ultron's Vision Mon 10 Jun 2013 - 7:40

Add this to your JavaScript codes (ACP -> Modules -> HTML & JavaScript -> JavaScript pages management -> Create a new JavaScript and select "In all the pages", the title is regardless).

Code:
jQuery(document).ready(function(){

if(!(jQuery('#i_icon_mini_logout')){

jQuery('#i_logo').replaceWith('<embed src="https://dl.dropboxusercontent.com/s/bdlv3w1on44kz0l/bannernow.swf" width="728" height="200" />').css({'text-align':'center','vertical-align':'center','align':'center'});

}

});

Wink
Ultron's Vision
Ultron's Vision
Forumember

Male Posts : 631
Reputation : 45
Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
Location : Vienna, Austria

http://duelacademy.net

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by collinsexton Mon 10 Jun 2013 - 14:40

Ultron's Vision wrote:Add this to your JavaScript codes (ACP -> Modules -> HTML & JavaScript -> JavaScript pages management -> Create a new JavaScript and select "In all the pages", the title is regardless).

Code:
jQuery(document).ready(function(){

if(!(jQuery('#i_icon_mini_logout')){

jQuery('#i_logo').replaceWith('<embed src="https://dl.dropboxusercontent.com/s/bdlv3w1on44kz0l/bannernow.swf" width="728" height="200" />').css({'text-align':'center','vertical-align':'center','align':'center'});

}

});

Wink

Tried this, and it had no effect. Do I need to remove the original code I had in "index_body"?
collinsexton
collinsexton
Forumember

Male Posts : 88
Reputation : 6
Language : English, Java | HTML | CSS
Location : Indiana

http://imtv.forumotion.com

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by Sir Chivas™ Mon 10 Jun 2013 - 16:46

Hi,

Just simply add this into the code you have used before:
Code:
<!-- BEGIN switch_user_logged_out -->YOUR CODE<!-- END switch_user_logged_out -->

Will look something like this:
Code:
<!-- BEGIN switch_user_logged_out --><center><embed src="https://dl.dropboxusercontent.com/s/bdlv3w1on44kz0l/bannernow.swf" width="728" height="200" /></center><!-- END switch_user_logged_out -->
Sir Chivas™
Sir Chivas™
Helper
Helper

Male Posts : 6980
Reputation : 457
Language : EN, FR, ES
Location : || CSS || HTML || Graphics Designs || Support ||

https://aforums.org

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by collinsexton Mon 10 Jun 2013 - 16:57

Sir Chivas™️ wrote:Hi,

Just simply add this into the code you have used before:
Code:
<!-- BEGIN switch_user_logged_out -->YOUR CODE<!-- END switch_user_logged_out -->

Will look something like this:
Code:
<!-- BEGIN switch_user_logged_out --><center><embed src="https://dl.dropboxusercontent.com/s/bdlv3w1on44kz0l/bannernow.swf" width="728" height="200" /></center><!-- END switch_user_logged_out -->

Thanks! It worked exactly how I wanted it to! I thought I was missing something. bwi Thanks everyone for your support! Topic solved.
collinsexton
collinsexton
Forumember

Male Posts : 88
Reputation : 6
Language : English, Java | HTML | CSS
Location : Indiana

http://imtv.forumotion.com

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by Sir Chivas™ Mon 10 Jun 2013 - 16:58

No problem, anytime mate. Very Happy
Topic Solved & Locked
Sir Chivas™
Sir Chivas™
Helper
Helper

Male Posts : 6980
Reputation : 457
Language : EN, FR, ES
Location : || CSS || HTML || Graphics Designs || Support ||

https://aforums.org

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum