The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Custom JavaScript for Guests

View previous topic View next topic Go down

Solved Custom JavaScript for Guests

Post by collinsexton on June 10th 2013, 3:57 am

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
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 on June 10th 2013, 6:25 am

@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
Forumaster

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

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by Ultron's Vision on June 10th 2013, 7:40 am

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
Forumember

Male Posts : 634
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 on June 10th 2013, 2:40 pm

@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
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™ on June 10th 2013, 4:46 pm

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 -->



Attention!
- Please provide your forum URL at all times.
- When the issue is solved, please mark it as solved.



Sir Chivas™
Support Moderator
Support Moderator

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

Back to top Go down

Solved Re: Custom JavaScript for Guests

Post by collinsexton on June 10th 2013, 4:57 pm

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
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™ on June 10th 2013, 4:58 pm

No problem, anytime mate. Very Happy
Topic Solved & Locked



Attention!
- Please provide your forum URL at all times.
- When the issue is solved, please mark it as solved.



Sir Chivas™
Support Moderator
Support Moderator

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

Back to top Go down

View previous topic View next topic Back to top


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