I am building a Modal window/overlay with CSS and Javascript for an email subscription form.
My plan is to Show the Modal when a visitor comes to a website and does not have a cookie set. I then set that cookie when they submit the form or click the close button I have on the Modal window. So on repeat visits if the cookie is there they will not have to see it.
The Modal windows has a background image that is around 75kb so I am trying to come up with the best solution to avoid users loading this image if there cookie is set (I realize it will likely be cached by tis stage)
So my question, in a CSS file for a class/id that has a Background image set, if that class/id has a property set to be hidden display: none; will it still download the image?
To directly answer your question, yes it will, at least for Chrome (might vary between browsers).
I tested using jsfiddle and looking at the network tab
http://jsfiddle.net/ytdun/4/
HTML:
<div id="test"><img src="http://images.google.com/images/nav_logo107.png"></img></div>
CSS:
#test { display:none }
to be sure that the image is downloaded.
what about if use
visibility:hidden;
and temporarily resize the element to 0x0.....
and when the element is now needed...
set again the visibility to
visibility:visible;
and then resize it to its true size...
using the visibility property...
it's like hiding on a invisibility cloak...
but's you're still there and not vanished...
or preload it using javascript
if (document.images){
preload_image_object = new Image();
image_url = new Array();
image_url[2] = "image.jpg";
image_url[3] = "imag2.jpg";
var i = 0;for(i=0; i<=3; i++)
preload_image_object.src = image_url[i];
}
Related
It's my first time to have this kind of problem. As you can see on the IMG tag, the image is not visible. I'm not sure what can cause this problem. When I copy the link and insert it in a new tab, the image is there. I tried to add a new class and define width/height but didn't fix the problem
#foreach (var theimg in Model.AdExtraImages)
{
<img src="~/adimages/#theimg.AdId/#theimg.Image" class="the-extra-image"/>
}
URL(copy/paste new tab, where the image is ok):
https://localhost:44374/ads/4/adimages/1015/0f25eed4-1413-4854-96a7-6cdfb2300d9e_esresr.jpg
Problem solved I disabled adblocker
If you want to see your image with enable adblocker,
Rename your ads and adimages to other names that do not include ads, advertisements, etc.
I've got a Kendo Datepicker that I'm displaying inside a Kendo Window and it shows like this:
The Datepicker is somehow bloated, with larger than usual fonts and size. Outside the Kendo window, the datepicker displays fine. Now, I was wondering if I could resize the datepicker, or the fonts in it, assuming downsizing the font would downsize the datepicker too.
I have tried adding this to the CSS:
.k-popup .k-calendar {
font-size: 10px !important;
}
And the result was odd:
It only worked partially because only the month name was reduced, the numbers remained large...
The main issue is that when opening the datepicker, it overflows outside the kendo window dimensions: I was looking for a solution that would allow me to downsize the datepicker so it would fit.
EDIT
I tried to add the k-calendar class:
#(Html.Kendo().DatePicker()
.Name("concessionTOD")
.Start(CalendarView.Month)
.Value(DateTime.Now)
.Format("yyyy-MM-dd")
.Culture("pt-PT")
.HtmlAttributes(new { #class = "k-calendar" })
)
but the result was this:
you can see in the above image the size of the input and month name are reduced, indeed, but the calendar itself keeps bloated.
EDIT 2
I learned that if the window is defined as an iFrame, the results inside may vary as an iFrame, as a regular webpage, requires a DOCTYPE as well as the html, head and body tags. I added this to the partial view that's inserted in the window and the result was this:
So, the calendar isn't bloated anymore but still overflows the window's height, causing a scroll bar to appear. To access the lower part of the calendar, I must use the scroll. As said before, I want the calendar to overflow outside the window, as shown in OnaBai's answer, without creating any scroll bars.
Also, I found in the documentation that
Refreshes the content of a Window from a remote URL or the initially defined content template. Note that passing data and non-GET requests cannot be sent to an iframe, as they require a form with a target attribute.
I'm not sure how to interpret the second sentence but it may help in dealing with the issue.
Use the following CSS selector / definition:
.k-calendar {
font-size: 10px;
}
Check the following code snippet.
$("#datepicker").kendoDatePicker();
$("#win").kendoWindow({
title: "window with datepicker"
});
.k-calendar {
font-size: 10px;
}
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.common.min.css" />
<link rel="stylesheet" href="http://cdn.kendostatic.com/2014.3.1119/styles/kendo.default.min.css" />
<script src="http://cdn.kendostatic.com/2014.3.1119/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js"></script>
<div id="win">
<input id="datepicker" value="10/10/2011"/>
</div>
OK, so I solved my issue, the telerik support proved most valuable. They reminded me that it is not possible to have an overflowed iframe.
So, I removed my iFrame setting from the Kendo Window:
#(Html.Kendo().Window()
.Name("addConcessionWindow")
.Modal(true)
//.Iframe(true)
.Visible(false)
)
and removed the script and style references I had in the html page the filled the window (so they won't be loaded twice).
Bottomline is:
it is not possible to have an overflowed iframe.
I was given a Wordpress theme to install for a new website and then asked to make some customizations.
The site is here: http://centergrovepto.org/townsend/ (I'm not sure where the original theme came from.)
There are 3 buttons along the right side of the front page slider. "Employers", "Candidates", and "Open Positions". The buttons were initially clickable and all they did was change the current slider image.
I'm trying to make them clickable so that they open the corresponding page. If you hover over each button you can see in the status bar that the link paths are setup correctly, but when I click the button nothing happens.
I'm guessing it is a CSS issue and some layer is covering up the actual buttons, but I don't know enough CSS to figure out what the cause is. I have the Firebug plugin for Firefox installed so I can more easily inspect the CSS. I've played around with changing the z-index of various elements, but I just can't get it to work.
I actually think it's your jQuery Faded plugin. It looks as if this:
if (o.pagination) {
if (o.autopagination) {
$t.append("<ul class="+o.pagination+"></ul>");
$c.children().each(function(){
$("."+o.pagination+"",$t).append("<li><a rel="+number+" href=\"#\" >"+(number+1)+"</a></li>");
number++;
});
}
$("."+o.pagination+" li a:eq(0)",$t).parent().addClass("current");
$("."+o.pagination+" li a",$t).click(function(){
current = $("."+o.pagination+" li.current a",$t).attr("rel");
clicked = $(this).attr("rel");
if (current != clicked) {animate("pagination",clicked,current);}
if(o.autoplay){pause();}
return false; //THIS LINE PREVENTS DEFAULT ACTION WHEN <a> LINK IS CLICKED
});
}
Is preventing the default action of your links. I'm not sure what will happen, but try commenting the "return false" line out. See if any unwanted side-effects happen. Otherwise, add this code to your (or what I assume is yours) custom.js file:
jQuery(".pagination ul li a").click(function()
{
window.location = this.href; //UPDATED FOR EPHRAIM
});
I'm not exactly sure why this is happining, because if you open the link in a new tab, it works perfectly. It's possible that it's a css problem, but more likely, it has to do with your HTML.
What I would try is adding a target to your link. This will tell it to open the link specifically in the window your in, which may solve the problem. (I haven't tested it myself though)
Instead of
Try changing it to one of the following:
Or, if that one doesn't work, try this one as well
Let me know if that helps!
as I've seen on your site, the 3 buttons are linked like this:
a href="/townsend/employers/"
But i think it should be like this to work because a href="/townsend/employers/" does not refer to anywhere in your server
try changing it like so:
<a href="http://centergrovepto.org/townsend/employers/">
I'm creating a responsive design but have run into a problem where the Facebook Javascript SDK code's div#fb-root is causing a horizontal scrollbar when the browser width is less than 590px. I've tested this on Chrome, Safari, and Firefox, but the issue only occurs in Firefox.
Should I just set div#fb-root to display:none or is there a better way of doing it?
Thanks!
EDIT: As requested, the code below is how I'm loading the SDK. When I don't load the SDK, the horizontal scrollbars disappear.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxx', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional initialization code here
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
The display: none is completely OK, since that <div> is not used for showing anything, it's a placeholder where all the FB scripts can be loaded into and appended to your page
Setting display:none made the scrollbar disappear, but when I used FB.ui(), no dialog showed.
I managed to solve it by wrapping #fb-root in another div:
<div id="fbdiv" style="width:0px;height:0px"><div id="fb-root"></div></div>
placed at the end of the body tag.
Hope that helps somebody.
As a side note this .fb-root also breaks sticky footers implemented with html { height: 100%; } body { display: table; height: 100%; } and footer footer { display: 'table-row'; width: 100% }
Facebook should fix this.
The problem with hiding the fb-root div arises when you want to make use of the apprequests API call. This places the dialog for sending app requests to friends in the div. If the div is hidden, the request dialog will never be shown. I found out about this the hard way.
You could just try setting the width of the div on page load or something similar.
I have run into this same problem and tried a slew of different CSS tricks to fix it.
Setting the width of fb-root or container divs doesn't fix the problem. Neither does any form of overflow:hidden. The only thing that has worked for me is indeed making fb-root hidden as Zoltan said. After doing this I tested the button several different ways and I am not seeing any broken functionality using with this method at least for myself.
If their script button is going to break people's sites FB really should be fixing this issue on their end.
NOTE: Firefox is the only browser this problem comes up with.
Here (and in Firefox only) it just showed two small empty "iframe-ish" windows in the middle of my page.
I solved using display: none, but Facebook should definitely fix this issue.
You should also be able to do:
#fb-root {
position:absolute;
left:-9999em;
}
and not have it cause a horizontal scrollbar. If for some reason you don't want to use display: none; you could then move it back with JavaScript/jQuery if you really need it shown.
put this in your css
#fb-root {
position:absolute;
left:0;
top:0;
visibility:hidden;
}
I want an animation modal (loading please wait) and when the page fully loads it disappears?
Using jQuery:
$(function() { $('#loading').fadeOut(); });
The rest is CSS and an animated GIF.
If you're using jQuery, try something like this:
$(function() {
var reqMgr = Sys.WebForms.PageRequestManager.getInstance();
reqMgr.add_beginRequest(ShowWait);
reqMgr.add_endRequest(HideWait);
});
function ShowWait() {
$("#Loading").fadeIn();
}
function HideWait() {
$("#Loading").fadeOut();
}
Then just have an element:
<div id="Loading">Loading, Please Wait...</div>
Style and position as you want with css, default it to have a display: none; though.
I recommend to write some simple html with your loading message (and may be a page mask to make it grayed) and place it at the beginning of the page. And at the end of page add script to remove that message and mask (see first answer). So users will see this message as soon as they get the html page (also some browsers support rendering of incomplete pages during loading of the page). See the code of this page for additional details.
This is my favorite way to make a modal popup. It does not use any AJAX, it's just pure HTML & CSS: http://www.webdesignerdepot.com/2012/10/creating-a-modal-window-with-html5-and-css3/
You can hook it up to code-behind instead of using hyperlinks (get rid of the opacity attribute and work with div.visble = true/false). Set the modal div visible as default, then when page load completes, set it to visible=false.