MyBB Community Forums

Full Version: If url is https:// then hide?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im using advanced sidebox to show feeds, obviously when i go into https mode feeds dont work.

So is it possible in js to wrap the rss feed back code in a div that will check the url for http or https if its the https then it will not show the feed box.

hopefully you can understand me.

anyone?
This is possible, yes.
if (location.protocol === 'https:') {
// Do https stuff
}
else
{
// Do other stuff
}
(2014-09-14, 01:20 AM)nth Wrote: [ -> ]This is possible, yes.

if (location.protocol === 'https:') {
// Do https stuff
}
else
{
// Do other stuff
}

I tried using that but it seemed to just break this....This is the code from inside my custom template in advanced sidebox - the only place i can edit it from...

------------------------------------------

<style type="text/css"  media="all">

/* begin styles for RSS Feed */

.rss-box {
	 margin: 0em;
	 width: 147px;
	 background-color: #f5f5f5;
	 border: 0px solid silver;
	 
}
.rss-items {
	margin-top:0px;
	padding:0.5em; 0.5em;
	margin-left:0px;
	color:#000000;
}
p.rss-title {padding:0.5em;}
.rss-title {
	font-size: 8pt;
	background-color: silver;
	color: gray;
	font-weight:bold;
	text-align: left;
}

.rss-item  {
  font-size: 7pt;
  list-style:none;
  padding-bottom:1em;
}

.rss-item a {
        color: #346cbc;
	font-size: 9pt;
	font-weight:bold;
        list-style-type: square;
	}
	
.rss-item a:visited {
	color: black;
}

.rss-date {
	font-size: 7pt;
	color: #000000;
	}



</style>
<tr>
<td class="trow1">
<script language="JavaScript" src="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fwww.infowars.com%2Ffeed%2F&num=13&date=y&targ=y&utf=y"  charset="UTF-8" type="text/javascript"></script>

<noscript><a href="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fwww.infowars.com%2Ffeed%2F&num=13&date=y&targ=y&utf=y&html=y">View RSS feed</a></noscript>

<script language="JavaScript" src="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fwww.drudgereportfeed.com%2Frss.xml&num=10&date=y&targ=y&utf=y"  charset="UTF-8" type="text/javascript"></script>

<noscript>
<a href="http://feed2js.org//feed2js.php?src=http%3A%2F%2Fwww.drudgereportfeed.com%2Frss.xml&num=10&date=y&targ=y&utf=y&html=y">View RSS feed</a>
</noscript>
</script>
</td>
</tr>




^ do you have template conditionals plugin installed ? it is required to use conditionals in the templates
 
Instead of hiding the boxes for people accessing over https, why not fix the problem by loading the javascript over https?

Replace every instance of http://feed2js.org//feed2js.php with https://feed2js.org/feed2js.php.
(2014-09-14, 03:07 AM).m. Wrote: [ -> ]^ do you have template conditionals plugin installed ? it is required to use conditionals in the templates

yeh im using PHP and Template Conditionals by ZiNgA BuRgA

(2014-09-14, 05:34 AM)Cameron:D Wrote: [ -> ] 
Instead of hiding the boxes for people accessing over https, why not fix the problem by loading the javascript over https?

Replace every instance of http://feed2js.org//feed2js.php with https://feed2js.org/feed2js.php.

Well i didnt know i could do that.....i was told on another forum that rss feeds just didnt work in https....Thanks for helping me.
(2014-09-14, 12:02 PM)dmpops22 Wrote: [ -> ]Well i didnt know i could do that.....i was told on another forum that rss feeds just didnt work in https....Thanks for helping me.

Depends on the site you're embedding from, because feed2js supports https it should work fine.
(2014-09-14, 03:07 AM).m. Wrote: [ -> ]^ do you have template conditionals plugin installed ? it is required to use conditionals in the templates

You don't need that plugin for the code I posted. The code I posted was Javascript and could be used as


<script type="text/javascript">
 if (location.protocol == 'https:')
 {
   document.write("yes");
 } else {
   document.write("no")
 }</script>