Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

Auto Pop-up on homepage


Reply

5 Posts   1942 Views

Avatar
Jay-Dee

29 December 2009 at 8:40pm Community Member, 11 Posts

Hello, I hope someone can help me with this one.

I am trying to add a temporary auto pop up window on my homepage, however pasting my .js script on the html editor doesn't seem to work.
I have added my script to my Page.ss file but now my pop up window comes up everytime any page loads.

Is there a way I can tell my pop up window to load only when my home page is loaded?

Thank you in advance and Happy New Year everyone!

Avatar
zenmonkey

3 January 2010 at 7:39am Community Member, 528 Posts

Wrap your js in a if Title==Home block (or whatever your homepage is called)

Avatar
Jay-Dee

11 January 2010 at 1:48pm Community Member, 11 Posts

Hello Zenmonkey, thanks for your reply, unfortunately I'm not sure I understand. I don't know much about js =$
Could you explain a bit more? thanks again.
Jay

Avatar
zenmonkey

12 January 2010 at 3:01am Community Member, 528 Posts

In you Page.ss Template you should wrap javascript in an if Block

<% if Title==Home %>
Script Goes Here
<% end_if %>

That way it will only load the script on a page whose title is Home

Avatar
Pigeon

12 January 2010 at 10:11am Community Member, 243 Posts

It would be much better to use the Class of the page in the if statement as then you will include it on all the pages of that type AND you will be able to have your users change the title of the page and it will still work.

eg:

<% if ClassName = HomePage %>
<script type="text/javascript">
alert('this is the home page');
</script>
<% end_if %>