I am trying to hide a button on the screen based on the URL containing the word SendEmail by looking inside the HREF tag and if there is a match... hide it!
The code works fine apart from there is another button with exactly the same markup, etc but the link shows SendEmailUsingOutlook (please see html below).
So i need to find the exact match of SendEmail and exclude SendEmailUsingOutlook.
P.S. I can't modify any of the HTML, CSS, etc this is generated by the system.
i am currently using:
Expand|Select|Wrap|Line Numbers
- window.attachEvent("onload",hideElement);
- function hideElement()
- {
- for(i=0;i<document.all.length;i++)
- {
- if(document.all[i].tagName=='A')
- {
- if(document.all[i].href.search(/SubmitEmail/i)>-1)
- {
- document.all[i].style.visibility = hidden;
- }
- }
- }
- }
Expand|Select|Wrap|Line Numbers
- <A CLASS=ButtonItem HREF="javascript:try{if(SubmitEmail (true)==true) self.document.EntryForm.submit();}catch(err){alert('The path to local file is incorrect, please use Browse button to select file.')}"><IMG SRC="/CRM/Themes/img/color/Buttons/SendEmail.gif" BORDER=0 ALIGN=MIDDLE></A>
- <A CLASS=ButtonItem HREF="javascript:try{if(SubmitEmailUsingOutlook(true)==true) self.document.EntryForm.submit();}catch(err){alert('The path to local file is incorrect, please use Browse button to select file.')}"><IMG SRC="/CRM/Themes/img/color/Buttons/SendOutlookEmail.gif" BORDER=0 ALIGN=MIDDLE></A></TD>