Optional Target (ie Content:) Pages

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Optional Target (ie Content:) Pages

Soporose
Is there any way I can display optional shadowbox pages on page-load depending on which condition is met? Perhaps I can best explain with an example:

<body  
<% If X=1 THEN %>
onLoad="open_shadowbox('/option1.html')"
<% Else If X=2 THEN %>
onLoad="open_shadowbox('/option2.html')"
<% Else %>
onLoad="open_shadowbox('/option3.html')"
<%End If%>
>

The only way I can get it to work is to declare the shadowbox page in the JavaScript with:

content: '/option1.html'

And then in the body tag...

onLoad="open_shadowbox()"

But that doesn't allow for any alternate target pages.

Is there a way to do this directly with shadowbox instead of trying to do everything with the one target page?
Reply | Threaded
Open this post in threaded view
|

Re: Optional Target (ie Content:) Pages

Soporose
Nobody?

Not even the publisher?

Reply | Threaded
Open this post in threaded view
|

Re: Optional Target (ie Content:) Pages

Wizzud
In reply to this post by Soporose
Where are the conditions (<% If X=1 Then %>, etc) being evaluated? At the server, or at the client (the browser)?
Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: Optional Target (ie Content:) Pages

Soporose
Thanks Wizzud.

The conditional code is asp - server-side.

Reply | Threaded
Open this post in threaded view
|

Re: Optional Target (ie Content:) Pages

Wizzud
Exactly. So why can't you do this...
<script type='text/javascript'>
window.onload = function(){
  window.setTimeout(function(){
        Shadowbox.open({
<% If X=1 THEN %>
            content: '/option1.html'
<% Else If X=2 THEN %>
            content: '/option2.html'
<% Else %>
            content: '/option3.html'
<%End If%> 
          , player: 'iframe'
          , width: X
          , height: Y
          , title: 'Title'
          });
      }
    , 10);
  };
</script>
...at the end of your HEAD section?
You can make the entire object part of the condition if you want to (eg. different widths, heights, titles).
It could even be that (just as a for instance) if X = 0 then there is no open-on-page-load required at all, so the entire <script ... /script> goes inside each condition (or an outer, encompassing condition).
Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: Optional Target (ie Content:) Pages

Soporose

Thanks very much for the shove Wizzud.

I was fixated on the "body on load" approach and missed the obvious -- also because I'm not very strong in JavaScript.

It's now working fine.