HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.

How do I add a script in the header?

BenBen
edited July 2005 in Vanilla 1.0 Help
I want to add the following line into the header on all pages, unfortunately I can't seem to find where I would put this... <script type="text/javascript"> <!-- if( top != self ){ top.location=self.document.location; } //--> </script> It's to break the page out of frames as otherwise the login doesn't work on my server.

Comments

  • edited July 2005
    you could write an extension i imagine...

    if (@$Head) { $Head->AddScript($Context->StyleUrl."framebreaker.js"); }

    and then have your js in an external file.

    i looked at the PanelHider extension and just quickly edited it down.
  • again, the documentation for extensions isn't available just yet.
  • MarkMark Vanilla Staff
    edited July 2005
    If I were you, I'd put my javascript into a .js file. Then create a new extension following the same comment methods adopted by existing extensions (ie. name it, version number, your name, etc) and then the only real php you'll need to add is this:

    $Head->AddScript("/path/to/your/js/file.js");
  • wow did we just say the same thing but different?
  • MarkMark Vanilla Staff
    There ya go. *wipes brow*
  • BenBen
    edited July 2005
    ok... I've created the following.

    My Extension
    <?php /* Extension Name: Break Frames Extension Url: http://soul-scape.com/ Description: Should add a script on every page to allow the site to break free from the constricting frames. Version: 1.0 Author: Ben Author Url: http://www.soul-scape.com/ */ $Head->Addscript("./js/BreakFrames.js"); ?>

    My Javascript
    if( top != self ){ top.location=self.document.location; }

    Now this still doesn't seem to be working, I'm not familiar with the intricacies of JavaScript so any help would be appreciated... :)
  • did you enable it in the admin? can we see a page where it would be ?
  • just looking at your login page, it says that the file doesn't exist on the server? are you sure you uploaded it?
  • while you're at it, give me a discussion list auto-refresher! ;)

  • omg use the feed :X
  • edited July 2005
    /* Extension Name: Break Frames Extension Url: http://soul-scape.com/ Description: Should add a script on every page to allow the site to break free from the constricting frames. Version: 1.0 Author: Ben Author Url: http://www.soul-scape.com/ */ if (in_array($Context->SelfUrl, array("index.php")) && $Context->Session->UserID > 0) { $Head->Addstring("META TAG TO REFRESH THE PAGE"); } ?>

    thhat would probably work
  • Hmm, during uploading, it seems to have renamed the file to lowercase. Just adjusting the reference in the extension to lowercase has fixed it. Thanks very much jonezy
  • ahh, now it's producing a header error message...

    Warning: Cannot modify header information - headers already sent by (output started at /home/soul-sca/public_html/vanilla/extensions/BreakFrames.php:15) in /home/soul-sca/public_html/vanilla/library/Vanilla.Session.class.php on line 27
  • maybe try wrapping the if statement around it.

    if (@$Head) { }
  • edited July 2005
    465446543217
  • for some reason, just re-uploading the file worked as well the problem seems to be solved, thanks everyone
  • you are welcome ben.
This discussion has been closed.