Pregunta

Hello I am passing an ID to a popup window and based on that ID I want to set a specific tab to visible or not. The Id being passed is "key2" and I am pulling that from the URL. The Id of the tab is "tabTwo". Below is my code that I have so far, the alert fires but the tab is still visible. Let me know if you have any thoughts on why this tab is still visible, thanks.

window.onload = function DealVis()
               {
                   var url = document.URL;
                   if(url.indexOf("key2") != -1)
                   {
                       alert("got it");
                       document.getElementById("tabTwo").style.visibility="hidden";
                   }
               }

HTML for tagTwo

<apex:tab label="New Land Deal" name="tab2" id="tabTwo">

    <apex:pageBlock id="newLandDeal" title="New Land Deal" >

      <apex:pageBlockButtons >
        <apex:commandButton action="{!saveNewLandDeal}" value="Save"/>
      </apex:pageBlockButtons>
      <apex:pageMessages />

      <apex:pageBlockSection columns="2">
       <apex:repeat value="{!$ObjectType.Land_Deal__c.FieldSets.NewLandDeal}" var="f"> 
          <apex:inputField value="{!landDeal[f]}"/> 
       </apex:repeat> 

      </apex:pageBlockSection> 
    </apex:pageBlock>

  </apex:tab>
¿Fue útil?

Solución

add this alert(document.getElementById("tabTwo")) next to the alert("got it"); and check if it can find your tabTwo element.

1- I think the problem might be the tabTwo is not your tab's ID.

or

2- your tab is being loaded after when window.onload happens. which is probably because your tabs is being created based on some Ajax requests and you have to wait until it is done.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top