Brian Wren
Brian Wren

Reputation: 377

Javascript Namespaces, onclick Event, et al

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.

Upvotes: 1

Views: 984

Answers (2)

Romain
Romain

Reputation: 1

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.

Upvotes: 0

Quentin
Quentin

Reputation: 944200

  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

Upvotes: 4

Related Questions