Scroll up button not working - scroll

I'm trying to put a scroll up (back to top) button in my blogger blog.
That should be, in principle, quite simple, but I don't why I can't manage to do it. Now after trying so many things I'm totally frustrated.
I'm using the following html code:
<a style="display:scroll;position:fixed;bottom:5px;right:5px;" href="#"><img src="url address of image" /></a>
The button is there as expected, but when I click on it, it reloads the blog instead of going to the top. Why?? no clue.
I tried to use an "id" in the logo image and link to it, and I've also tried to use in the blog head a name tag "name=Top" and link it with href="#Top".But it doesn't matter. It always reload the blog instead of going to the top.
For instance, when I'm inside a post and I click on the button it goes to the main page instead of scrolling up within the post.
If you want to check it yourself, please do it. My blog is cortarcoserycrear.blogspot.com
Whatever help you can provide me it would be very appreciated because I don't know what's happening.
Thanks.

You should be using Javascript/JQuery to do this.
Refer to this question: How to scroll to top of page with JavaScript/jQuery?

What I finally used to solve my problem was:
Button html:
<a style="display:scroll;position:fixed;bottom:5px;right:5px;" href="#wrap" class='go-to-top' title="Back to top"><img src="image url" /></a>
Body html:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'/>
<script>
$(function () {
$('.go-to-top').click(function () {
$('html,body').animate({
scrollTop: 0
}, 500);
return false;
});
});
</script>

Related

jquery mmenu opens by default

I've set up a new page and added jQuery.mmenu. now when I load the page the mmenu opens already by default.
mmenu is firing and adding mm-opened on the body on page load. Then the css transition kicks in and mmenu is opened nicely.
But I want it only to be opened when click on a menu button. Very strange. Anybody heard this before?
jquery:
$(document).ready(function() {
$("#my-menu").mmenu();
});
html:
<body>
<nav id="my-menu">
<ul>
<li>But WHy?</li>
</ul>
</nav>
<div>//content</div>
</body>
Nothing special going on in the markup
Add this to your css stylesheet and test it:
#my-menu:not(.mm-menu) {
display: none;
}
Add "mm-wrapper_sidebar-closed" class to html tag.
I added in html (javascript):
window.location.hash = "menu";
Ivan, I upvoted you because it made me realize that the issue for me is related to the hash, thanks : ).
If you're not opening the mmenu programmatically with JS, it instructs you to have a link with the href property set to the selector of the menu that you want to open. So I have something like:
...
to target the menu selector with an ID of navbar-menu. What I didn't realize was I had clicked on this link before all of my JS code was in place, so the current URL still had a hash in it pointing to the menu selector. e.g.
https://yourdomain.com/#navbar-menu
I'd refresh the page and the menu would just open automatically. Because mmenu allows you to use a hash to define the state of the menu - open when the hash corresponding to the menu selector is in the URL.
FYI for anyone who is running into the same issue. If the menu is opening automatically, remove the hash.
You can use the "initial" option under the sidebar addons.
sidebar: {
collapsed: {
use: '(min-width: 450px)',
hideNavbar: false,
},
expanded: {
use: '(min-width: 992px)',
initial: 'closed'
},
},
reference: https://github.com/FrDH/mmenu-js/issues/967

Mouseover image change

I am trying to make a blur image change on mouseover. Something like camera zooming in and out with certain things get blurred when other is zoomed in. Best way to understand what I want is to see it here:
http://berger.co.rs/test/test.html
And I have only one problem. The mouseover image is always behind the active image. I need to have only active image and when mouseover is applied, then to change images. Also, I don't want active image to disappear in total, and then to load mouseover image. I need it like on example above, just not to have mouseover image shown behind all the time.
You can see whole code I have inside of the page source.
Can you please help me?
First welcome to Stackoverflow, as a new user, please read this guide so you can ask better and get better and quicker answers:
https://stackoverflow.com/help/how-to-ask
please avoid code on comments. If someone ask you for additional code, include it in the question.
Now the answer:
The problem is just that you didn't provide Jquery for $() commands to work. "alturl.com/bcfhv" isn't correct.
here, put this on file, it's working:
<html>
<body>
<style>
div{
position:relative;
width:714px;
height:420;
overflow:hidden;
}
span {
position:absolute;
top:0px;
left:-0px;
}
</style>
<div>
<img src="http://berger.co.rs/test/img/mouseover.png" width="714" height="421"/>
<span>
<img src="http://berger.co.rs/test/img/active.png" width="714" height="421"/>
</span>
</div>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function() {
alert('ok')
$("div").hover(function() {
$("span").fadeIn();
}, function() {
$("span").fadeOut();
});
})
</script>
</body>
</html>
Or see it working here

Link to anchor tag on a different page not working in Firefox

I have a link at the bottom of a page, and its purpose is to link to an anchor on a different page. It doesn't seem to work in Firefox (at least, not in v8). Instead, on load it goes right to the very bottom of the page.
Any help is appreciated!
Source: http://msi.emsix.com/news/1900/1/Six-in-Ten-Employers-Hope-Health-Care-Reform-will-be-Repealed.aspx (the "Susan McIntyre" link at the bottom)
Anchor markup:
<h3 id="mcintyre" name="mcintyre">Susan McIntyre</h3>
Try adding the following code:
<a name="mcintyre"></a>
<h3 id="mcintyre">Susan McIntyre</h3>
This works correctly if I disable javascript.
It looks like what happens is that the scroll is done before you use script to collapse away a bunch of the content. So the final scroll position ends up wrong.
If you're collapsing the content away async, that could do it...
If you are unable to create <a name='%hashName%'></a> anchor, consider this:
$(document).ready(function(){
$(window.location.hash).append('<a name="' + window.location.hash.replace('#','')+ '"></a>');
window.location.href=window.location.href;
});
I know it looks weird, but works fine.
Since today I haven't heard about div anchor tags. Are you sure it is proper to expect such kind of behaviour from browsers?

Open a hidden div in a lightbox with Mootools in Joomla 1.5

I am using Joomla 1.5.22 with Mootools 1.1. I have a module with a form contained in a hidden div that I want to open in Joomla's built in modal box. The problem I have is that when I click the link the form opens in the modal box, but it also opens the div in the module on the page.
HTML:
<div id="moduleBox">
<div id="clickMeButton"><a id="formClick" class="modal" href="#hiddenForm">Click me</a></div>
<div id="hiddenForm">
form code goes here
</div>
</div>
Javascript:
window.addEvent('domready', function() {
$('formClick').addEvent('click', function(){
$('hiddenForm').setStyle('display','block');
});
});
So how do I get the form to only show up in the modal box?
You can see what I am talking about here - http://www.internextion.com/
It's the Call Back Module. I already added the handler: 'adopt' as suggested below, now the result is a little different. The target div still shows up below the link, but now the modal window contains the link rather than the target.
I think this uses Harald's SqueezeBox - in which case, you are looking at the following scenarios:
find the target div and CLONE it to insert into the modal box.
find the target div and ADOPT it into the modal box.
you are seeing the first (default) case. to achieve the second effect, add:
handler: 'adopt'
to the instantiation options. more here: http://digitarald.de/project/squeezebox/1-1/showcase/get-elements/
Option 1:
If you look at the html code (in firebug) for the overlay div you will see that it makes a "copy" of html and places inside the overlay container with id="sbox-content". In theory if you add a CSS like below +/-, it will hide the link and display everything else. This might be the simplest and easiest solution.
div#sbox-content > a#formClick{
display: none;
}
Option 2:
If option 1 does not work for some reason, you can try playing with CSS and hide the link when the Modal box opens and then making it visible when it closes.
Modify the JS to add a class instead of modifying the style.
window.addEvent('domready', function() {
$('formClick').addEvent('click', function(){
$('formClick').addClass('hidden');
$('hiddenForm').setStyle('display','block');
});
});
Load additional CSS that will make the link invisible
div#clickMeButton.hidden {
display: none;
}
Then you will have to overload closing event and make the link visible...
Ok, so I finally got it to work with a combination of the other answers given. First, I removed the javascript click event to make the form appear, that solved the issue of the form showing up below the link. Next, I added new CSS for the hiddenForm ID within the modal box and set that to display:block. It appears that the default handler behavior (in Joomla at least) is to adopt the content since I have removed the handler: 'adopt' and it is still adopting the content.
I knew it was something simple, thanks for the help!
BTW - the link is still live, you can see the correct behavior on the demo site. Now all I need to do is add some fancy AJAX form submission and it will be ready for prime time.

AJAX modal dialog, fire onload if referer == <whatever>

I'm trying to change my index.html to show a modal window if the referer to my site == (eg, if they come from Google, show a "Welcome Googler" dialog box with an image inside of it).
I'm using FancyBox, but I'm not married to it.
Any suggestions on how to code it? I'm a C++ programmer -- Javascript isn't my forte, so straight examples would be very much appreciated.
Thanks in advance.
You're going to need a couple things: document.referrer, and jQuery UI. jQuery UI makes dialog boxes trivially easy.
You can find an in depth example from the documentation page but for the most part, this is what you are going to need:
<script type="javascript/text">
if (document.referrer.indexOf('google.com') > -1){
$("#my-dialog").dialog("open");
}
// this is the jquery code to set up the dialog box
$(function() {
// options would go inside the dialog() function
$("#dialog").dialog();
});
</script>
Needed HTML:
<div id="my-dialog">
This is where things get displayed
</div>

Resources