Forums | Mahara Community

Developers /
Links & Resources Menu


Gordon McLeod's profile picture
Posts: 197

07 November 2012, 23:07

Hi,

When using version 1.4 I added a javascript link that opened an accessibility toolbar at the top of the page - it was developed and hosted at Southampton University and was ideal as it was unobtrusive and only appeared if the user wanted it. Unfortunately after upgrading to 1.5 the link doesn't work - it now displays "bad link" at the start of the code - I've pasted the working orignial version below in quotes, though it might get stripped out.

"javascript:(function(){d=document;lf=d.createElement('script');lf.type='text/javascript';lf.id='ToolbarStarter';lf.text='var%20StudyBarNoSandbox=true';d.getElementsByTagName('head')[0].appendChild(lf);jf=d.createElement('script');jf.src='http://access.ecs.soton.ac.uk/ToolBar/channels/toolbar-stable/JTToolbar.user.js';jf.type='text/javascript';jf.id='ToolBar';d.getElementsByTagName('head')[0].appendChild(jf);})();"

Can anyone suggest a way to get this working again - ideally as a link on the resources menu as that's where our students expect to see it.

Thanks, Gordon.

anonymous profile picture
Account deleted
Posts: 197

08 November 2012, 18:24

Hi Gordon,

Do you mean that you had put this chunk of Javascript into one of the links and resources boxes which were expecting a plain url?

If yes, then this change is due to a fix for a security bug, as allowing javascript in those boxes is a risk (it can be combined with other as-yet-undiscovered security issues, rogue staff, etc) and the person who maintains the code on the server should be the one who gets to put potentially risky stuff in.

You could still put this chunk of javascript in the theme.

Your file called htdocs/theme/raw/templates/sideblocks/linksandresources.tpl currently looks like this:

        <div class="sidebar-header"><h3>{str tag="linksandresources"}</h3></div>
    <div class="sidebar-content">
{if $sbdata}
    <ul id="linksresources">
{foreach from=$sbdata item=item}
      <li><a href="{$item.link}">{$item.name}</a></li>
{/foreach}
    </ul>
{/if}

</div>

So what you need to do, is change it to this:

        <div class="sidebar-header"><h3>{str tag="linksandresources"}</h3></div>
    <div class="sidebar-content">
{if $sbdata}
    <ul id="linksresources">
{literal}
        <li><a href="javascript:(function(){d=document;lf=d.createElement('script');lf.type='text/javascript';lf.id='ToolbarStarter';lf.text='var%20StudyBarNoSandbox=true';d.getElementsByTagName('head')[0].appendChild(lf);jf=d.createElement('script');jf.src='http://access.ecs.soton.ac.uk/ToolBar/channels/toolbar-stable/JTToolbar.user.js';jf.type='text/javascript';jf.id='ToolBar';d.getElementsByTagName('head')[0].appendChild(jf);})();">The Accessibility Link Text</a></li>
{/literal}
{foreach from=$sbdata item=item}
      <li><a href="{$item.link}">{$item.name}</a></li>
{/foreach}
    </ul>
{/if}

</div>

Once that's done, it should work. I just tested it and the toolbar appeared.

Thanks,
Melissa.

Gordon McLeod's profile picture
Posts: 197

08 November 2012, 22:20

Hi Melissa,

Brilliant, thanks - I tried it on our test site and it works perfectly.  I'll make that change to the live site.

Regards, Gordon.

3 results