I have a popup with a yes or no question (radiobuttons) in it. I want to force the users of my site to select either one of the options before closing the popup, but i am not able to do so. I can simple close the popup using the 'RED' cross button on the popup.
Can anyone tell me how can i stop the users from navigating from this page? Is there a way to display a alert message and ask them to choose an option?
I am using C#.net, asp.net and JavaScript.
There is no 100% way to hold the user of your site... You could show a selfmade popup something like this
#popupBox {
position: fixed;
width: 100%;
height: 100%;
background: rgba(0,0,0,.4);
}
#popup {
position: absolute;
width: 300px;
height: 200px;
left: 50%,
margin-left: -130px;
top: 50%;
margin-top: -100px;
}
<div id='popupBox'>
<div id='popup'>
<button type='input' value='yes'>
<button type='input' value='no'>
</div>
</div>
After the insert of your popup ho have to reload the needed javascript for handel the click to one of this buttons...
Related
I want to check if our advertisement(picture or flash) has successfully displayed on website page.But the element can not be found in page source.
I get the element in chrome Developer tools.
<div id="QQcom_all_Rectangle:1" data-loc="QQcom_all_Rectangle" data-index="1" style="height: 250px; display: block; width: 300px; position: relative;" class="l_qq_com" adconfig_lview="l.qq.com" adconfig_charset="gbk" adconfig_lview_template="http://l.qq.com/lview?c=www&loc={loc}" oid="1800716433" display="banner">
<a class="absolute a_cover" href="http://c.l.qq.com/lclick?loc=QQcom_all_Rectangle&click_data=dXNlcl9pbmZvPW9CM2pnVGd4RnhHNyZhZHhfZXh0PSZwY3RyPTUwMSZhdmVyPTUwMTIwMSZwcmk9eHRiQkZXc0ovclloYXdzdWZqRmpSTkhyZWFuL3pQU2omYnRwcmk9R3VBL25heHhnY3JyNTdrdVNCNW4yWis3TlJqM01nTmw=&oid=1800716433&soid=gmLndBibVj/1bQtQRjKVNkVKAV1Q&dtype=0&pctr=501&aver=501201&btoid=100418428&pri=xtbBFWsJ/rYhawsufjFjRNHrean/zPSj&btpri=GuA/naxxgcrr57kuSB5n2Z+7NRj3MgNl&index=1&page_type=2&chl=703&k=%E6%9B%9D%E7%81%AB%E7%AE%AD%E5%B7%B2%E8%A3%81%E6%8E%89%E6%B5%B7%E8%80%B6%E6%96%AF%20%E5%9B%9E%E5%BD%92%E4%BC%91%E5%9F%8E%E4%BB%85%E4%B8%80%E5%91%A8%E5%BE%81%E6%88%982%E5%9C%BA%2C%E6%B5%B7%E8%80%B6%E6%96%AF%2C%E7%81%AB%E7%AE%AD%2CNBA&t=%E6%9B%9D%E7%81%AB%E7%AE%AD%E5%B7%B2%E8%A3%81%E6%8E%89%E6%B5%B7%E8%80%B6%E6%96%AF%20%E5%9B%9E%E5%BD%92%E4%BC%91%E5%9F%8E%E4%BB%85%E4%B8%80%E5%91%A8%E5%BE%81%E6%88%982%E5%9C%BA_&r=&s=" target="_blank" rel="nofollow" style="position:absolute;width:300px;height:250px;left:0px;top:0px;cursor:pointer;z-index:10;background-color:#fff;filter:alpha(opacity=0);opacity:0;"></a>
<div class="absolute" style="position: absolute; width: 24px; height: 16px; left: 26px; bottom: 0px; cursor: pointer; display: none; z-index: 20; background: url(http://ra.gtimg.com/web/res/icon/report_default_new.png) 50% 0% no-repeat;"></div>
<div style="position: absolute; left: 0px; bottom: 0px; width: 26px; height: 16px; z-index: 12; background: url(http://ra.gtimg.com/web/res/icon/leftbottom_new.png) 100% 0% no-repeat;"></div>
<div class="absolute" style="position:absolute;width:18px;height:18px;right:0px;bottom:0px;cursor:pointer;z-index:20;background:url(http://ra.gtimg.com/web/privacy/white_icon.png) no-repeat;"></div>
</div>
but in page source,it only shows
<!--$loc$_div AD begin...."l=$loc$&log=off"--><div id="QQcom_all_Rectangle:1" data-loc="QQcom_all_Rectangle" data-index="1" style="height:0;" class="l_qq_com"></div><!--$loc$ AD end --><!--[if !IE]>|xGv00|c5668531d36ed7899852180841ca2aa2<![endif]-->
how can I get the 300px_250px image url?
anyone knows?
Yeah! That's simply because of the fact that there are DOM manipulation libraries which alter the Document-Object Markup and not the source.
You have to understand the difference between the DOM and the physical page source. The physical page source helps render the DOM, after which it can be modified by using libraries; since you can't change the source on the server side as it needs to be re-rendered for different people, only the DOM is changed. In very simple words, DOM is what the browser has rendered: it's like a copy of the source which has been, then, modified by the libraries.
Using a library like jQuery can do this easily.
var $element = $( "#QQcom_all_Rectangle:1" );
if ( !$element || $element === null ) {
console.log( "The element hasn't been rendered. Not found.");
}
But if it is not YOUR page, and you can't really modify it and/or get the data. You can try doing this with a web-kit emulator like PhantomJS or Selenium web-kit. Since these are just testing frameworks, you can't create a fully fledged JavaScript applications.
Theoretically, you can:
Render this in a WebKit (Browser Rendering Component)
Get the source of the DOM
Use it
But that's just in theory because you need to use some language to create an application like that and since it's outside the scope of your question, you can't.
Using selenium webdriver can handle this.
WebElement QQcom_all_Rectangle=driver.findElement(By.id("QQcom_all_Rectangle:1"));
List<WebElement> links=QQcom_all_Rectangle.findElements(By.tagName("a"));
String style=links.get(0).getAttribute("style");
I am trying to use jScrollPane to scroll through my gallery that is inside of an iframe. I am using the jQuery code for iframe scrolling from the official example.
Using this code doesn't work for my images (it just hides the original browser scrollbars, doesn't throw any errors and refuses to scroll), but it works perfectly if I replace my images with multiple paragraphs so they overflow (just like in the example).
EDIT: I forgot to mention that images scroll perfectly using the default browser scrollbar.
EDIT #2: Made a JSFiddle.
Here's how my gallery is structured:
...
</head>
<body>
<div id="content"> // Used the same way as in the example, works with text
<div class="gallery">
<div class='picture'>
<img class='pin' src='something'/>
<div class='wrapper'>
<img class='thumbnail' src='something'/>
<img class='border' src='something' />
</div>
</div>
<div class='picture'>
...
</div>
</div>
</div>
...
And here's the CSS for gallery and pictures:
.gallery {
position: relative;
width: 98%;
}
.picture {
float: left;
position: relative;
display: list-item;
list-style-type: none;
width: 11%;
}
.picture .pin {
position: absolute;
left: 48%;
width: 13%;
}
.picture .thumbnail {
position: absolute;
width: 89%;
margin-top: 19%;
}
.picture .border {
position: absolute;
width: 100%;
}
I ignored margins and some other irrelevant stuff, but you get the idea.
The jQuery code is exactly the same as presented in the example.
I think the problem is that images are loaded after scrollbar is initialized, and scrollbar does not detect container size changes by default. If you read documentation carefully, you can see next:
Demo showing how autoReinitialise can also be used so that content
with images in it displays correctly in jScrollPane
So, try autoReinitialise option. If it won't help - update your question with example of your iframe on jsFiddle.net
Solved it!
Apparently, the script didn't like the absolute position of my .picture .pin. Changing it to relative and restyling a bit solved my issue.
Updated JSFiddle
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Is it possible to attach a div to an image? As in, to make the div follow the image? I have a web app where the user can click on a part of the page, and the image moves to it with easing. I'd like a speech bubble to follow the image and remain above it, but I'm having trouble finding out what this requires.
Any guidance is appreciated!
Regards
When I should do this, I would make a Div containing your image and the div of the speech bubble.
<div class="topelement">
<img src="#" />
<div class="speechbubble"></div>
</div>
Then when the user clicks on the certain part of the page, you can move the div with de class "topelement".
Hope this helps
If this is the element which user needs to clicks:
<div id="showImage">
Show the image
</div>
Once the user clicks that, the below slider will be shown
<div class="divSlider">
<img src="http://images6.fanpop.com/image/photos/33100000/justin-bieber-2013-justin-bieber-33194067-1295-1500.jpg" />
<div class="speechbubble">Your bubble message here!</div>
</div>
CSS:
.speechbubble {
background-image: url("http://www.clker.com/cliparts/K/k/N/x/a/k/dialog-bubble-rectangle-md.png");
width: 100px;
height: 100px;
background-size: contain;
background-repeat: no-repeat;
z-index: 100;
right: 0px;
position: absolute;
padding: 20px 30px;
color: red;
}
.divSlider {
width: 350px;
height: 300px;
position: relative;
display: none;
}
img {
float: left;
width: 300px;
}
By default am hiding the div in CSS itself.
now jQuery:
$(function() {
$("#showImage").click(function(){
$(".divSlider").fadeIn(2000);
});
});
Working Demo
I was looking at the javascript picture control on google search page and I was wondering how I could replicate it. I can see it blows up a picture on the hoverover but I cant find the code they are using in html.
Can some one help me.
I just responded to a similar question # Jquery Image popout on hover -- my answer was a CSS3 example.
Also, see http://jsfiddle.net/Kai/x4Frn/
Look at the source:
<div id="hplogo-..." style="background-color: rgb(153, 77, 51); position: absolute; width: 201px; height: 121px; left: -28px; top: 31px; z-index: 17;">
<div style="overflow: hidden; top: 6px; left: 6px; position: absolute; height: 109px; width: 189px; ">
<a href="/search?q=...">
<img src="/logos/..." border="0" style="position: absolute; left: -1px; top: -110px; ">
</a>
</div>
</div>
The first <div> positions the image and adds a background color. The second <div> hides the overflow to avoid that the image get's out of the box and is placed 6 pixels from the first div, which creates a border. On top of that, the image is placed, and because it is a sprite, it has some offset.
Hovering the first div will change the width and height of the first two divs and will reposition the first div.
I was just going through this beautiful website. Can anybody tell me how that designer has shown "The magic is loading" thing :
http://danielhellier.com/showcase/danielhellier/
The image just disappears as soon as the site is loaded complelely.
He is using javascript.
Look at the file http://danielhellier.com/showcase/danielhellier/js/jquery.bits.js
in the first line he fades out the loading div once the site has loaded:
$(window).load(function () {
$('#loading').fadeOut('slow');
});
The loading div:
<div id="loading">
<div align="center">
<p>The magic is loading</p>
<img src="img/loader.gif" alt="Loader" />
</div>
</div>
The CSS for the loading div:
#loading {
background: none repeat scroll 0 0 #1E1E1E;
color: #FFFFFF;
cursor: wait;
height: 100%;
overflow: hidden;
position: absolute;
width: 100%;
z-index: 100;
}
Notice how the z-index is high to put it on top of everything and the height and width are 100% to make it take up the entire window with its opaque background.
Also he put that <div> before the rest of the HTML. So it will be loaded first and the JavaScript to remove it is triggered by the load event on the window which will not be triggered until everything has loaded.
A very nice effect.