In facebook fan page tab application I click tab button and like to go to the specific
portion of the fan page content without pixel calculation.
For example to point the comment box.
for that purpose url http://www.facebook.com/pages/AAAA/4444444?sk=app_UUUU8&app_data=php
and
<div id="php"><textarea name="a"></textarea></div>
is in body
but I would like to achieve that goal automatically using Javascript?
will this do?
link
You could always style the link as a button, if you must.
Simply, Connect is enough to do that instead.
<button onclick="document.getElementById("php").scrollIntoView()">Go</button>
or
<button onclick="document.getElementById(location.hash.substring(1)).scrollIntoView()">Go</button>
is a javascript alternative to using the anchor
try the following code on click of the button
window.location.href="#php";
You can go to any part of the body using the above code and providing the id of the content you wish to go....
Related
I am new to programming and I have a question. I have my main web page (boton) with three buttons and I want to create a function so that the button can open a page (pagina1 or pagina2) with Google App Script or GAS. How can I do that? I just have this, which is the structure of the buttons on the boton page.
and this is how it shows on the page
Well, Instead of using "GAS" you can use the anchor tag of HTML
Like :- here is an example - Google
You need to change the website link and your button text, and BOOM!
Thanks ;)
Add the '_blank' in your script:
<button class="btn" onclick="window.open('https://stackoverflow.com', '_blank');">stackoverflow</button>
Well, Instead of using "GAS" you can use the anchor tag of HTML
Like :- here is an example - Google
You need to change the website link and your button text, and BOOM!
I'm using a plugin on my site to enable quiz functionality. When a lesson/quiz has been completed by a user there is a popup that features a button with a link back to another page. The problem I have is that I need to change this link.
This is what console looks like:
View Console
I need to be able to edit the href link shown here so that I can redirect users to the correct page. Firstly I need to know if this is possible and secondly how I could go about implementing this change.
I'm presuming it can be achieved with JS, but my knowledge of JS is limited so I'm unsure about the execution.
You can change attribute href as simple as any other attribute:
$('a.gdlr-lms-button').attr('href', 'new-url');
With jquery you can do it like this.
Where test the classname is so just replace that by gdlr-lms-button
$('a.test').attr('href', 'www.google.be');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a class='test' href="www.facebook.com">Hello</a>
I'm sorry for asking a simple question as I'm still learning html/css/js. What I want to do is to be able to click on this button that is a div class made from css and js, to load it's content without refreshing the page, which I believe requires ajax or jquery, but not sure how. Here is my github page danielroberto.github.io and the repo https://github.com/danielroberto/danielroberto.github.io so you can get an idea of what I mean. I basically want to click on any of the navigation buttons and then loads whatever content I want without redirecting to whole new html page. For example, when I want to click on the "photography" button, I want the button effect to happen while my images load on the bottom without redirecting to something like photography.html. Similar to clicking on the "design" button, I want it to transition and load my content.
There is a wealth of resources on the net to get the intro you need to AJAX - the technique of loading parts of a webpage instead of the whole thing.
You correctly suggest that you could use the jQuery JavaScript library to do this - there are lots of alternatives, but that's easy to learn, and is widely used on the net. Tried and tested!
Start here: http://www.w3schools.com/jquery/jquery_ajax_intro.asp
That would only be if you are planning to use some server-side technology to serve up your images.
If you are just going to manually set a list of images to show, and you want the buttons to cycle through these, then you're probably best just to build a carousel of some kind, using a jQuery carousel plugin, and include it all in your HTML markup from the beginning. Loads to choose from or get inspired by here: https://plugins.jquery.com/tag/carousel/.
Also, you should size your images to fit the screen you are serving them to. I recommend you look at using srcset. Your image on the test site was 4600px wide! Check this out: https://css-tricks.com/responsive-images-youre-just-changing-resolutions-use-srcset/
I hope it goes well. The early days can be hard work but you'll soon get the hang of it.
You could store your content in a var in your js. Then when your button is clicked you can call the function which creates a text node or an element and append that to your div.
HTML
<button onClick="function()"></button>
<div id="show-data">
</div>
JS
var newText = 'Stuff here';
function function() {
var div;
div = document.getElementById('show-data');
div.appendChild(document.createTextNode(newText));
}
You can easily edit the html of an element when clicking a button using jQuery
HTML
<div class="my-button">click here</div>
<div class="my-content">init content</div>
JS
contentElement = $('.my-content');
$('.my-button').click(function() {
contentElement.html('new content');
});
https://jsfiddle.net/jaxon58/zp9mvu38/
i will try to explain very simple:
I'm calling a div trough a href tag like this:
Injectie
<div id="injectie">
<p>some text</p>
</div>
It's working well but I need to achieve this thing: let's say my link of the page is www.example.com . i would want that when i click the link to call the div the url of my page will change in something like this:
www.example.com/#injectie but without leaving the page. The way I made it it only calls the div but without changing the url.
Is there a way to make this happen?
What you could do is put the page url into the link, instead of only the anchor's ID.
Injectie
<div id="injectie">
<p>some text</p>
</div>
Since you don't want your page to reload, this question might be helpful:
Modify the URL without reloading the page
Yes instead you need to use scroll to function available in Jquery which will not change the URL but scrolls to the element you want.
.scrollTo( target, options, [, complete] )
Ex:$('body').scrollTo('#injectie');
to change the url without reload use this
function processAjaxData(response, urlPath){
document.getElementById("content").innerHTML = response.html;
document.title = response.pageTitle;
window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", "www.example.com/injectie");
}
It's not possible to change the whole url to another website without loading this website directly for serious security reasons.
Spoofing the actual website you are on would be way too easy and fisher would cerebrate a huge blowout.
You only can change your url behind the # without triggering a website reload on the client side.
And if you find a way to do the impossible nonetheless i wouldn't be surprised if you get a bounty from the affected browser company. ;)
Edit:
as Tirupathi Raju pointed out its possible to change the html5 browser history so you can change everything after the domain/ip eg. http://example.com/<here you could fiddle around>
I want to use same div tag for different page displaying using html. how to use it
Ex:<div id ="name"> if{page1}else{page2}</div> is there any possible using if in html or give different solution plz.
when user clicks different tab the different page need to appear i used different div but click different tab it shows some empty space with the page2 i think that is page1 space.
Given that a page might have ids #page1 and #page2 and the <div> has an id of #brian
you could use jquery:
$('#page1 #brian').html(some_html_here);
$('#page2 #brian').html(some_html_here);
This example may aid you - http://jsfiddle.net/wQCDR/
Alex
If you don't want to use PHP in your HTML code you can use SSI (server-side include). Basically, you can include html files within other html files. Here's a link to read more:
http://httpd.apache.org/docs/1.3/howto/ssi.html
Cheers
you can don this usign javascript
get url first and according to that write content to particular div using
document.getElementById('one').innerHTML = "Content";