How to Use the New Javascript


So, cna someone please explain how to use this new capability? What goes in the JavaScript Box and what goes on the webpage?


  • thaen
    Posts: 940

    I'm copying this from nuadaria's post on the other thread ...


    if(document.getElementsByClassName('wiki-edit').length < 1){
    var siblingDiv = document.getElementsByClassName('wiki-page-container');
    var div = document.createElement('div');
    div.innerHTML = '<div class="wiki-edit"><a class="button" href="'+window.location.href+'/edit">Edit This Page</a></div>';

    siblingDiv[0].parentNode.insertBefore(div, siblingDiv.nextSibling);

    Copy that code exactly, and then paste it in the Campaign Settings -> Advanced -> Custom JavaScript box.

    Then click Save.

    Then go to any Wiki Page in your Campaign, and scroll down to the bottom of the main section, and you'll see the button for "Edit This Page".  You'll probably want to add some CSS to position it, but otherwise, it should work as is.

    You don't need to put anything on the Wiki Pages themselves to make this work.  Part of the power here is similar to the Custom CSS where you make change in one place (the Advanced tab) and it affects (or can affect) everything in the Campaign.

    Does that answer the question?


    Obsidian Portal Developer

  • Keryth987
    Posts: 992

    Seems to work. So I just add things java wise there and thats it then?

  • thaen
    Posts: 940

    Yeah, just like Custom CSS.  (Let me know if I'm not fully understanding your question?)

    Just noting, "Java" and "JavaScript" are two separate programming languages.  So, if you were googling for some "Java" code to show a popup, that code wouldn't work.  But, if you were googling for some "JavaScript" code to show a popup, that code would work.


    Obsidian Portal Developer

Sign In or Register to comment.

July 2022
Signs and Portends

Read the feature post on the blog
Return to Obsidian Portal

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!