Note that there are some explanatory texts on larger screens.

plurals
  1. POButton handling and layer visibility in Greasemonkey
    primarykey
    data
    text
    <p>I have a Greasemonkey script that I've been building for a game. The idea is to have info about the game in a div that will pop up when a button (which is added by my script) on the page is clicked.</p> <p>I'm using z-index because when I just display the div over the top of the game screen, some of the images show through. So, basically what I need to do is change the z-index of my div based on the value of a variable and/or button click. However, I cannot get my div to come to the front when I click my button.</p> <p>Here's what I have so far:</p> <pre><code>// ==UserScript== // @name Test Script // @namespace http://therealmsbeyond.com/ // @description Test // @include an_include.js // @include another_include.js // @require json.js // ==/UserScript== var VERSION = 1; var WEBSITEURL = 'http://therealmsbeyond.com/'; var SCRIPTNAME = 'Test'; var SENDINFODELAY = 600000; var UPDATEDELAY = 604800000; var ZINDEX_UNDER = -100; var ZINDEX_OVER = 111111; var Options = { 'mapVisible' : false, 'showHostile' : false, 'showAlliance' : false, 'showBookmarks' : false } function custom_setValue(k,v){ GM_setValue(k,v); } function custom_getValue(k,dv){ return(GM_getValue(k,dv)); } function custom_deleteValue(k){ GM_deleteValue(k); } function getSavedInfo(){ return(custom_getValue('ajaxparams',null)); } function getSavedServerId(){ return(custom_getValue('sid')); } var e = document.createElement('div'); var idAttr = document.createAttribute('id'); var styleAttr = document.createAttribute('style'); idAttr.nodeValue = 'shadow_map_container'; styleAttr.nodeValue = 'background-color:white;top:150px;left:75px;position:absolute;height:600px;width:600px;'; e.setAttributeNode(idAttr); e.setAttributeNode(styleAttr); var c = '&lt;strong&gt;This is the map window.&lt;/strong&gt;'; e.innerHTML = c; document.body.appendChild(e); if(Options.mapVisible == true) { document.getElementById('shadow_map_container').style.zIndex = ZINDEX_OVER; } else { document.getElementById('shadow_map_container').style.zIndex = ZINDEX_UNDER; } function showHide() { if(Options.mapVisible == true) { document.getElementById('shadow_map_container').style.zIndex = ZINDEX_UNDER; Options.mapVisible = false; } else { document.getElementById('shadow_map_container').style.zIndex = ZINDEX_OVER; Options.mapVisible = true; } } var btnStr = '&lt;a class="navTab" target="_top" onclick="showHide();return false;" href="javascript:void(0)"&gt;&lt;span&gt;Shadow Mapper&lt;/span&gt;&lt;/a&gt;'; var myNavContainer = document.getElementById('main_engagement_tabs'); var inner = myNavContainer.innerHTML; var newStr = btnStr + inner; myNavContainer.innerHTML = newStr; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload