eZ Community » Forums » General » ezxml and JavaScript
expandshrink

ezxml and JavaScript

ezxml and JavaScript

Thursday 28 December 2006 2:38:37 pm - 13 replies

The ezxml link tag doesn't allow to insert JavaScript. When trying to do so, you will get a validation error:

Using scripts in links is not allowed, link '...' has been removed

What do you think is the best solution to insert JavaScript into an ezxml field?

Thursday 28 December 2006 5:42:13 pm

First thought would be a custom tag or within a literal. Though it depends on the use - coding into a template for a custom tag isnt the more practical and i've not tried a literal for js in years (!).

Whats your purpose for the js?

Paul

Thursday 28 December 2006 6:55:23 pm

I want to insert bookmarklets (http://en.wikipedia.org/wiki/Bookmarklet ).

Friday 29 December 2006 12:49:47 am

Hi Kristof

Can't you just use an onClick attribute?

Claudia

Friday 29 December 2006 1:37:55 am

Use a custom tag!

<i>http://ezpedia.org/wiki/en/ez/custom_tags</i>

There are years of posts about everything you could need to know about custom tags scattered on ez.no

And with the 3.8 release they are simpler to use within the online editor while editing ezxml content object attributes.

//kracker

Friday 29 December 2006 10:09:26 am

Thanks for the feedback.

I think the onclick event won't work, since the bookmarklet should be bookmarkable.

I tried a custom tag and that works fine.

Maybe there are still other (and safer) ways to accomplish this. If other users can post on a site then they can also use your custom tag.

Anyone ever used a seperate object containing the JavaScript and embedded that with the embed-inline tag? It sounds overkill but when non-privileged users are not allowed to create or edit the JavaScript objects, then there's no danger for XSS attacks.

Friday 29 December 2006 10:31:32 am

Why not use a custom tag which does not accept or use user input (via attributes) or content input (inline custom tag)?

//kracker

Friday 29 December 2006 11:46:46 am

That's a possibility too. What if I want to add several bookmarklets to an article?

a) I need to add different custom tags for each bookmarklet.
b) I add a switch in the custom tag view template. Depending on a custom tag attribute it inserts the right bookmarklet.

Friday 29 December 2006 12:22:51 pm

What if I want to add several bookmarklets to an article?

a) I need to add different custom tags for each bookmarklet.
b) I add a switch in the custom tag view template. Depending on a custom tag attribute it inserts the right bookmarklet.

 

In response to item, a
- Question: What exactly will differentiate one final rendered bookmarklet code snippet from another from within the same content attribute / document.

In response to item, b
- Question: Why must custom tag attributes be used to insert the right bookmarklet? (Dependant on answer to above)

- Comment: This would go against processing or using user input in the creation of the custom tag / bookmarklet (to prevent security vulnerabilities related to code injection) unless you have a set standard switch cases say of 1,2,3,4 which insert the correct bookmarklet. It just seems to snow ball quickly downhill once you start accepting user input (let alone informing users of accepted input).

- Comment: Because it sounds like a bookmarklet needs a title and a url. the client knows the url and the url's document name. I don't see why your bookmarklet could not be entirely client side js code and avoid this problem entirely. If you have to say pass it a url via js that's simple enough to grab from within the custom tag via the wrap_operator or other method. If you have to say pass it a url document name, say you grab the current document's name + site title from within the custom tag.

- Comment: I still don't see why user input is needed to include a snippet of code which passes your bookmarklet code snippet the needed argument per instance; a name and url detected via php, tpl or js. A good bookmarklet will pop open a browser based dialog with the ability to alter the default name on the client side.

//kracker

It's what I was thinking, I still should not have posted it ..

Friday 29 December 2006 12:34:56 pm

<b>Question: What exactly will differentiate one final rendered bookmarklet code snippet from another from within the same content attribute / document</b>
Answer: the title and the content of the href attribute. I meant adding different (~several) bookmarklets.

<b>unless you have a set standard switch cases say of 1,2,3,4 which insert the correct bookmarklet</b>
Exactly what I meant with b)

Friday 29 December 2006 2:44:02 pm

I've just tried using literal and it seems to work fine.

Friday 29 December 2006 3:20:43 pm

Hmmm, it looks like the link does go through but the brackets are mangeld by eZ in the db sad.gif Emoticon

Monday 01 January 2007 11:45:27 am

Please tell me how to add Google Analytics to my site.
Thanks,
Tally

Monday 19 November 2007 3:20:49 pm

<i>@Tally Amara</i>
<i> > Re: Please tell me how to add Google Analytics to my site.</i>

Hello,

While this conversation has come to a close we would like to add the following note to future forum archive readers searching for a similar solution.

BC Website Statistics is a product (an extension) certified by eZ Systems, supported by Brookins Consulting, and a flexible proven solution for integrating Google Analytics with eZ Publish. This extension has been created to provide eZ Publish customers seeking a complete, ready to use, out-of-the-box solution integrating eZ Publish with the Google Analytics web statistics reporting service.

BC Website Statistics, http://ez.no/products/certified_extensions/bc_website_statistics

Cheers,
Brookins Consulting

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from