Shadowbox.open()

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

Shadowbox.open()

nolandubeau
Hi,

I'm trying to spawn a shadowbox window by calling it like this:

function viewReel(){
                Shadowbox.open({
                type:       'html',
                animate:     false,
                assetURL:    '../view/reel.cfm',
                height:     500,
                width:      700  
    });
}

The shadowbox opens successfully however it does not load my page called reel.cfm, but rather displays the string "../view/reel.cfm" within the shadowbox window.  Of course, i'm looking to actually load reel.cfm within the new shadowbox.  Am I missing parameters?

thanks.

Nolan
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

p9939068
I believe you should be using content instead of assetURL
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

nolandubeau
when I change the property to content:    '../view/reel.cfm', shadowbox opens with '../view/reel.cfm' as a string within the shadowbox window.  it does not actually render reel.cfm

any help would be appreciated.

thx.
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

p9939068
maybe you should test with absolute path first.
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

Gordon K
I'm having a similar problem, and tried it with an absolute path, but to no avail. I'm using shadowbox.open with type="html". In this case, I'm trying to display a file with .java extension. Shadowbox displays the file name  instead of the contents.

I wondered if I should be using a different Shadowbox type, but none of the others seem appropriate - it would be great if there were a flag to tell Shadowbox to interpret the file as plain text.

Has anyone found a way to work around this? As a worst case, I guess my Javascript code could load the file contents into a string var and pass that to Shadowbox, but it wouldn't be my first choice.
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

Wizzud
The object passed into open() is defined in the documentation (v1 read 'type' instead of 'player')

The definitions of the allowed values for type/player are defined in the documentation

Quoting for 'html' : "...Injects some pure HTML code into the Shadowbox display..."

A file path/url is not "pure HTML code", but it will be treated as such if that's what you tell Shadowbox it is!

If you want to open() a web-displayable 'page' in Shadowbox, use type/player 'iframe', giving the file url in the content property.

NB : Shadowbox does not (currently) support ajax-type insertions of code (HTML) segments.

Combine literacy with curiosity and a whole world of information opens up to you
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

Gordon K
Thank you, Wizzud. I see your point about the "html" type. I tried it with "iframe" instead, and now it does load the contents of plain-text files IF it's a file with an extension it already "knows" about - for example, .txt or .php. However, when I try to display a different extension (.java in this case), it instead pops up an open/save dialog over the Shadowbox window - as if the file type is unsupported by Shadowbox... and this is despite the fact that I had explicitly defined the mapping of file types for Shadowbox like so:

                var sbMimeMap = {
            img:        ['png', 'jpg', 'jpeg', 'gif', 'bmp'],
            swf:        ['swf'],
            flv:        ['flv'],
            qt:         ['dv', 'mov', 'moov', 'movie', 'mp4'],
            wmp:        ['asf', 'wm', 'wmv'],
            qtwmp:      ['avi', 'mpg', 'mpeg'],
            iframe:       ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php',
                        'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml',
                        'txt', 'vbs', 'java']
            };
               
                Shadowbox.open({
                                content:    url,
                                type:       "iframe",
                                title:      sbTitle,
                                handleException: "Shadowbox error",
                                initialHeight:350,
                                initialWidth:450,
                                loadingImage:"loading.gif",
                                handleUnsupported:  'link',
                                ext: sbMimeMap
                        });

The other relevant point is that I can point Shadowbox to the same file via an  tag (ie, using 'rel="Shadowbox"', and it loads it just fine, displaying the text contents. It's only when loading via Javascript that it has this problem. Any ideas? Many thanks for the help!
Reply | Threaded
Open this post in threaded view
|

Re: Shadowbox.open()

Wizzud
The last 6 properties of the object you are passing into open() are all options (see NOTE), and are not properties of the object that Shadowbox expects to receive from an open().

If you were to initialise with...

Shadowbox.init( { initialHeight:350
                       , initialWidth:450
                       , loadingImage:"loading.gif"
                       , handleUnsupported:  'link'
                       , ext: sbMimeMap
                       } );

...and then subsequently call open() with...

Shadowbox.open( { content:    url
                         , type:       "iframe"
                         , title:      sbTitle
                         } );

...it might stand a better chance of working.

NOTE : the use of 'type' and 'loadingImage' indicates that you are using version 1, but handleException is not an option for version 1 so I have not included it!

There is a possible alternative, because shadowbox will accept options on a 'per-link' basis. But certain options are documented (for version 2!) as being set-able only via init() - 'ext' being one. And for version 1, I suspect that there may be others, such as 'loadingImage'. I am not certain how rigidly this is enforced (if at all), or of the effect if ignored; nor I am entirely sure that options are applied consistently or logically within galleries, for example, but still...

In theory, you might therefore be able to use...

Shadowbox.init( { ext: sbMimeMap } );

...and then subsequently call open() with...

Shadowbox.open( { content:    url
                         , type:        "iframe"
                         , title:         sbTitle
                         , options :   { initialHeight:350
                                          , initialWidth:450
                                          , loadingImage:"loading.gif"
                                          , handleUnsupported:  'link'
                                          }
                         } );

But personally I would put as many options into init() as possible!
Combine literacy with curiosity and a whole world of information opens up to you