I have added some codes in “C:\inetpub\SolarWinds\Orion\Controls\PageHeader.ascx” which adds the 'Search for Nodes' element on every SolarWinds webpages in the page header.
In order to prevent form resubmission message popup when page is refreshed I try to use “onClick” function instead of using the Submit button. The IE and other browsers (Chrome, FF, ..) seem have different way to handle the onClick event, so in IE the “search” will be a button but not submit button, in other browsers it will be text.
Also, you can just type in the search criteria and hit ‘enter’ then the search will execute (search by node name by default)
The codes are:
<div style="font-family:arial;color:#FFFFFF;font-size:10pt;font-weight:bold;padding-top:3px;">
<form id="MySearchForm" name="MySearchForm" onSubmit="returnfalse;"
>
Find <input id="MySearchText" name="MySearchText" type="text" size="10" style="font-size:10pt;" onkeypress="var searchStr = MySearchText.value; var propertyStr = MySearchProperty.value; if(event.keyCode==13 && searchStr!=''){window.open('/Orion/NetPerfMon/Resources/NodeSearchResults.aspx?'+'Property='+propertyStr+'&SearchText='+searchStr);}"/> By
<select id="MySearchProperty" name="MySearchProperty" size="1" style="width:100px;font-size:10pt;">
<option value="Caption">Node Name</option>
<option value="IPAddress">IP Address</option>
</select>
<![if !IE]>
<a id="mySearchLink" onClick="var searchStr = MySearchText.value; var propertyStr = MySearchProperty.value; if(searchStr==''){alert('Node name or IP must be filled out!');} else {window.open('/Orion/NetPerfMon/Resources/NodeSearchResults.aspx?'+'Property='+propertyStr+'&SearchText='+searchStr);}">
Search</a>
<![endif]>
<!--[if IE]>
<button id="mySearchButton" onClick="var searchStr = MySearchText.value; var propertyStr = MySearchProperty.value; if(searchStr==''){alert('Node name or IP must be filled out!');} else {window.open('/Orion/NetPerfMon/Resources/NodeSearchResults.aspx?'+'Property='+propertyStr+'&SearchText='+searchStr);}">
Search</button>
<![endif]-->
</form>
</div>
I have tested the code in IE, FF & Chrome, same results from FF & Chrome, but not IE:
Firefox V17 and Chrome V27
when press enter with empty search string, page refreshed only
when press enter with non-empty search string, page refreshed and results opened in a new page
when click “Search” text with empty search string, alert message displayed, not refresh page
when click “Search” text with non-empty search string, results opened in a new page and not refresh page
IE 9,
when press enter with empty search string, alert message and page refreshed
when press enter with non-empty search string, page refreshed and results opened in a new page
when click “Search” button with empty search string, alert message displayed AND refresh page
when click “Search” button with non-empty search string, results opened in a new page and refresh page
I notice it will take a bit longer to load the webpages when you first to load pages after making the changes, but it will be back to “normal” after a few loads. (Not sure why, may be refresh the caches?)
Hope this is useful.
PLEASE MAKE BACKUPS BEFORE YOU CHANGE THE FILE.
PLEASE TEST THE CODES BEFORE APPLY TO LIVE SYSTEM.
USE THE CODES AT YOUR OWN RISK AND FEEL FREE TO MODIFY THEM.
Thanks
update:
================================
add onSubmit="returnfalse;" in <form Tag>, now when press "Enter", page NOT refresh any more in IE and others, also NOT refresh when click Search Button in IE. BUT in IE when press Enter, search result page open twice, not in other browsers. Why? any help? Thanks