Forum Discussion

lorna's avatar
lorna
Maven
11 years ago

Javascript in a blog

Hi,

 

We have a blog where the author wants to post a link to a page that opens in a specific window size... it's a product demo so they would like it to appear over / with the blog if that makes sense.

 

I can't get JavaScript working (window.open) in a blog... is there any way to do this in a blog?

 

Thanks!

  • You could introduce a JS file into the main theme that looks for a certain class on links <a> and adds a click event to these links allowing you to fire your custom window open code when they are clicked. Then just add this special class to these links via the post blog HTML editor. 

  • KaelaC's avatar
    KaelaC
    Lithium Alumni (Retired)

    Lithium strips out javascript from messages as a security precaution.  I do not there is a way to post javascript into the message body. 

    • cblown's avatar
      cblown
      Boss

      You could introduce a JS file into the main theme that looks for a certain class on links <a> and adds a click event to these links allowing you to fire your custom window open code when they are clicked. Then just add this special class to these links via the post blog HTML editor. 

      • lorna's avatar
        lorna
        Maven

        Thank you all! Chris's worked for our requirements :)

  • You could possible create a link with target="_blank", and embed the resizing code within the linked-to page.

     

    Alternatively, you can embed iframes within blog articles, which might work depending on what effect you're trying to achieve.

    • Embedding JavaScript inside an iframe within a blog article would work if the platform didn't convert the JavaScript inside to plain text. But it does, every time.