1

Is this

<input type="button" value="..." 
  onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={/Pages/Home.aspx}' ) }"
/>

the same (functionally) as

. . .
<script type="javascript/text>
  function runIt() {
    ddwrt:GenFireServerEvent('__commit;__redirect={/Pages/Home.aspx}' );
  }
</script>
<body>
    <input type="button" value="..." 
      onclick="runIt();" />
</body>
</html>

I don't really understand

  1. what role the term "javascript:" in the onclick event description serves. I mean, isn't it the default that what is in the onclick will be javascript?

  2. what role the outer curly braces serve in the ..."javascript: {}".

  3. I recognize that "ddwrt:" is a namespace, but I am not aware of how to specify a namespace within a javascript function, which itself is located within a <script> block.

6
  • Don't the outer curly braces in the inline version serve to create an object which has a single field ddwrt to which it then assigns the outcome of the GenFireServerEvent function? (The object would subsequently be discarded so I don't know what purpose it serves, but still) Commented May 22, 2014 at 15:25
  • 1
    @Bart, nope, it is parsed as a statement block containing a label (ddwrt:) followed by a function call (GenFireServerEvent(...)). Note that surrounding the braces with parentheses or applying an operator would change that story. Commented May 22, 2014 at 15:26
  • Is that because it's not being assigned to anything? Is that what makes the difference between parsing it as an object and parsing it as a block? Commented May 22, 2014 at 15:30
  • 1
    @Bart, preemptively answered in my previous comment :) Commented May 22, 2014 at 15:31
  • So then, Frédéric, what purpose or function does the label serve? Commented May 22, 2014 at 16:42

2 Answers 2

4
  1. It is a label, and completely useless in this context
  2. They create a block, also useless in this context
  3. No, it is another label and also useless
Sign up to request clarification or add additional context in comments.

3 Comments

You're right, the last part of my comment was wrong. The third case is also parsed as a label.
So Quentin, ...="javascript: GenFrSvrEv('__cmt;__redir={/Home.aspx}' )" (abbrev'd for the purpose of this post) would operate the same?
onclick="GenFireServerEvent('__commit;__redirect={/Pages/Home.aspx}')" would operate the same.
0

In this particular case (Sharepoint) this is NOT javascript, this is parsed by Sharepoint and translated in something like:

onclick="javascript: __doPostBack('ctl00$ctl37$g_c251e0c4_cd3d_4fc0_9028_ab565452bedd','__cancel;__redirect={https://....}')"

have a look at the result source code. That's why you can't call GenFireServerEvent in your javascript code.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.