On a page I have a Tweet button, like this:
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
The problem is that in the bubble with counts of tweets is the value 2197, which is incorrect.
How to put there the correct value?
Thanks
The problem is that you're specifying:
<a ... data-url="false" .../>
Twitter reads this value as the URL you're wanting to share, and is ultimately under the impression that the URL "false" has been shared 2,197 times. If you want to share a static URL, this attribute must relate to the URL of the page you're wanting users to Tweet about. If your page was http://example.com, for instance, you'd use:
<a ... data-url="http://example.com" .../>
(Which has been shared 1,492 times).
If you want to share the URL of the page the button is added to, you'd simply remove the data-url parameter altogether:
<a href="https://twitter.com/share"
class="twitter-share-button"
data-lang="en"
data-count="horizontal"
data-text="#{tw_listing(#data)}">Tweet</a>
If you need help with creating your Tweet button, you should refer to the official creation page at twitter.com/about/resources/buttons.
Related
On my base.html I have 2 links which lead to the same post_form.html and use the same forms.py.
Link:
<a class="list-group-item list-group-item-light" href="{% url 'post-create' %}">Submit</a>
Problem is, I would like to hide/show part of the page depending on which link did user select. How can I do that? Below is script I use to hide a field, but I don't know which link did they use. (currently the links are the same, don't know what to add to make a change on the page 'post_form.html)
<script type="text/javascript">
function on_load_1(){
document.getElementById('div_id_type').style.display = 'none';}
on_load_1();
</script>
Hello recently I'm facing a new problem. I used a custom html code in the middle section of my website. After implement the html my website automatically go to that section after loading. I think this is the culprit:3
<div class="results" id="results">
<a class="domain" href="#" id="domain">helloworld.com</a>
</div>
Here there is an hash tag that force browser to go to this particular section. That is to say I used "javascript:void(0)" instead of # but nothing improved.
My question is how can I push browser to say header and not to follow that result id.
Simple use javascript
It will changes hash in url from anything to your required header
Make sure your header has the id attribute header.
window.location.hash = "header";
You can prevent the browser to follow a link (with an assigned href) with some simple JS code:
document.getElementById("domain").onclick(e => e.preventDefault());
Where e is the Click event object.
Although a javascript:void(0) on the href property should do the trick too.
You should probably also set the link's rel property to nofollow, like this:
<a class="domain" href="#" id="domain" rel="nofollow">helloworld.com</a>
I'm having an issue with urls.
I have a navbar.ejs file that I include in every page of my website via
<% include ./navbar %>
In the file, I have something like this:
<li><a id="loginButton" href="../login">Login</a></li>
<li><a id="signupButton" href="../users/new">Sign up</a></li>
The issue I'm having is that depending on where I am on the website, the login button might or might not work. This is because of
"../login"
So at times when you click the login button, you're directed to
https://baseurl/login
At other times, it goes to
https://baseurl/campgrounds/login
This URL is wrong and doesn't exist.
I know the source of the problem obviously. But how do I get replace "../login" with an absolute URL path... As in, how do I go back to the root?
Something like
$("#loginButton).attr("href", document.location.hostname + "/login") doesn't work because it just directs to
baseurl/baseurl/login
which is also invalid
If the URL of the login page will always be https://yelpcamp-asool.c9users.io/login then the below code will work fine.
<a id="loginButton" href="/login">
In the Component Template section of this angular tutorial, they use the following code:
...
<ul class="phones">
<li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query | orderBy:$ctrl.orderProp" class="thumbnail">
<a href="#/phones/{{phone.id}}" class="thumb">
<img ng-src="{{phone.imageUrl}}" alt="{{phone.name}}" />
</a>
{{phone.name}}
<p>{{phone.snippet}}</p>
</li>
</ul>
...
In the anchor tag they use following value for href "#/phones/{{phone.id}}". As far as I know href="#" would jump to the top of page on click. And href="#mydiv" would jump to the element with id mydiv.
I've never seen something like href="#/folder1/myimg.jpg". Is it equivalent to href="/folder1/myimg.jpg"?
Putting the "#" symbol as the href for something means that it points not to a different URL, but rather to another id or name tag on the same page. For example:
Click to go to the bottom of the page
blah blah
blah blah
...
<a id="bottomOfPage"></a>
However, if there is no id or name then it goes "no where."
for more info you can see ...
What is href="#" and why is it used?
But in angularJS it is used for routing the request ... as angularJS provide very good support to built Single Page Application .. the parameter after # used to find out proper page to render ....
here is a nice example .. but you need time to understand it in depth ..
It seems like all anchor events will be interrupted by javascript and perhaps page will be loaded on background using ajax and browser's address line will change but it will not be cause for browser to reload the page. In HTML4 it was unable to change address line without reloading the page. So It's kind of workaround to:
Specify which page should be loaded by js.
Give the user ability to refer to specific page in future or share it.
I'm kinda new with php and ajax, so I need a little bit of help here. I'll explain my concept a little bit, please give me feedback is it possible or not.
this is a little bit of my code for the main page :
<ul class="treeview-menu">
<li id = 'menu1'>
<a>
<i class="fa fa-angle-double-right"></i>
Menu1
</a>
</li>
</ul>
<div id="content_info" style="display:none;"></div>
<div id="content_data" style="display:none;"></div>
<div id="content_input" style="display:none;"></div>
I have two other page, lets called it form_view.php and form_input.php. the form_view.php is used to show data from the database, and the form_input is used to input new data and edit old data. I'm planning to use AJAX for loading the form_view and form_input on the main page.
First, when I choose Menu1, it will show the content_data div and hide the other two div. Then, it will load form_view.php inside the content_data div. I'm using tables for viewing the data and there's an edit button for each row. When I click the button, the form will be submitted to form_input, and the form_input will show the data that's been chosen.
Is it possible to make form_input show the data that's been chosen and load it in the content_input div? When this is happens, content_data and content_info will be hidden, and content_input will be shown. Is it possible to not refresh the main page while doing so?
And if it's all possible, can you show me some example for the code?
I appreciate any feedback. Thanks.
Encode the data in the url request for form_view.php
$( "#content_data" ).load( "ajax/form_view.php?"+parameters );
Make sure to url encode your parameters. The later retrieve the data from $_GET in your PHP.