0

I had 2 websites www.example-with-prices.com and www.example-without-prices.com.

Both sites are basically the same, except one doesn't show the prices of the products and it's a lot of trouble to maintain both sites.

Now I rebuild these websites and want to have just one website and place the price information in <div> what is shown just if you use www.example-with-price.com.
I try to use something like this, but I can not find a way to hide if the user go to my site using www.example-without-prices.com

<div id='hideshow' data-value="price1" style="display:none">    
<table>  price table here </table> 
 </div>

<script>
    $('[id^="hideshow"]').on('click', function(event) {
      var dataValue = $(this).attr('data-value');
      dataValue = $('#'+dataValue);
      $(dataValue).toggle('hide');
    });
**  <!-- add something what toggle hide if user enters site via www.example-without-prices.com -->


</script>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Richard de Ree
  • 2,329
  • 4
  • 30
  • 47

3 Answers3

1

Added by default to hide - Then show if not a no price host

<style>#hideshow{display:none}</style>
<div id='hideshow' data-value="price1" style="display:none">    
<table>  price table here </table> 
 </div>

<script>
    $('[id^="hideshow"]').on('click', function(event) {
      var dataValue = $(this).attr('data-value');
      dataValue = $('#'+dataValue);
      $(dataValue).toggle('hide');
    });
**  <!-- add something what toggle hide if user enters site via www.example-without-prices.com -->

if (window.location.hostname !== 'www.example-without-prices.com') {
    $('#hideshow').show();
}

</script>
ratiorick
  • 572
  • 3
  • 7
  • thank for giving this solution, however I didn't got it worked. I've made with the suggestions an other solution, which i've posted here too. – Richard de Ree Oct 10 '16 at 08:50
1

I can use something like this:

if(window.location.href == 'www.example-without-prices.com'){
    //your code
}
0

I found a better solution in another post which i want to share.

<script>
    if(window.location.href == 'www.example-without-prices.com')
        {
            $('#price1').hide();
        } else {
            $('#price1').show();
        }       
</script>



<div id='price1'>  
       <!--- price table>
</div>
Richard de Ree
  • 2,329
  • 4
  • 30
  • 47