Thursday 15 May 2014

Adding PHP code to Drupal Page for adding Javascript -


I am trying to open a link in a popup on some drop pages without javascript address bar and so on. I have learned that you can not just embed JS in the "Full HTML" view. (Commented on script tags with HTML tags) I used the API function using the PHP function drupal_add_js (), but with the HTML code the php code is commented with comment. I.e

  & lt ;? Php $ myscript = 'function open window () {var browser = navigator.appName; If (Browser == A Microsoft Internet Explorer ????) {window.opener = self; } Window.open ("/ page / terms-use", "null", "width = 900, height = 750, toolbar = no, scrollbars = no, location = no, resizable = yes"); Window.moveTo (0,0); Window.resizeTo (screen.width, screen.height-100); Self.close (); } '; Drupal_add_js ($ myscript, 'inline'); // If $ myscript points to a theme .js file then change 'theme' to the other ultimate? & Gt;   

When pages are viewed, it appears in the browser as follows:

    

I used to use the PHP filter module to give the page creator user to use PGP, but still the same happens. Is it because of a rich text editor? But why is it also in PHP code mode?

This is usually controlled by a custom module or theme function. But assuming that your code should work, being placed in the field on the node. This issue is likely to be a text format setting. Assuming that Drupal 7, you can go to / admin / config / content / formats. I think you are using PHP format. So you want to inspect the settings for this format and make sure PHP filter is enabled.

No comments:

Post a Comment