I am trying to make something similar like Google on IE. They create a "Make Google your homepage" script for IE.
This is what I have so far:
<script type="text/javascript">
$(document).ready(function () {
$("#no_thanks").click(function () {
$(".lightbar").hide();
}); });
</script>
<!--[if IE]>
<div class="lightbar">Come here often? Make xxx your homepage.
<span class="sure">Sure!</span>
<span class="nothanks"><a id="no_thanks" href="#" onClick="_gaq.push(['_trackEvent', 'HomePage', 'No', 'Set as Home page']);">No Thanks</a></span>
</div>
<![endif]-->
I also added some Google Analytics.
What happens is that the script works, it does set the homepage, but the "lightbar" doesn't disappear when I restart the browser (i'm not talking about the jQuery script).
Any ideas?
Imho there is no solid way.
the best you could do is to add a querystring to the url that is under the add-as-homepage link. like:
www.example.com/homepage.html?isbookmark=true
or
www.example.com/homepage.html?ishomepage=true
then just check if the querystring exists in the url when the document is called. Then it is initiated from this button or a bookmark or a homepage.
Related
I have a real .php page like this http://hiteachers.com/soccer_parse.php?id=5. I want to add it into a blogger.com new page (**not a new blog post, or new HTML widget **, and I've got this successfully.
https://tranbongda.blogspot.com/p/function-myfunction-window.html
I used the code like this:
<script>
var Window;
// Function that open the new Window
function windowOpen() {
Window = window.open("http://hiteachers.com/soccer_parse.php?id=5",
"_blank", "width=400, height=450");
}
// function that Closes the open Window
function windowClose() {
Window.close();
}
</script>
<button onclick="windowOpen()">Open page</button>
<button onclick="windowClose()">Close page</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script>
$(document).ready(function()
$("button").click(function(){
$("#div1").load("http://hiteachers.com/soccer_parse.php?id=5");
});
});
</script>
My expectation is that I'd like the blogger page to load the original content of the .php page immediately when the visitor visits the blogger.com page (https://tranbongda.blogspot.com/p/function-myfunction-window.html) without clicking on any button.
I have thought of creating iframe by using this:
<iframe name="Framename" src="http://hiteachers.com/soccer_parse.php?id=5" width="550" height="550" frameborder="0" scrolling="yes" style="width: 100%;"> </iframe>
But the blogger.com page does not accept it, and returns the error message like this:
This page contains HTTP resources which may cause mixed content affecting security and user experience if blog is viewed over HTTPS.
Then I moved to try this <object width="500" height="300" type="text/html" data="http://hiteachers.com/soccer_parse.php?id=5"></object> as per some bloggers' suggestions, but I still failed.
Some other bloggers suggested to use AJAX, which is very new to me.
So, is there any way to parse the provided .php page content and add it to the blogspot.com/blogger.com new page without showing the url of the .php page or window pop-ups?
Can you help me please?
Thanks
As the bloggers likely have suggested, make the PHP server a REST endpoint and access the data on the blog site with Asynchronous JavaScript and XML. Although today people have tended to scratch the XML part and go with JSON or something.
AJAX is accomplished by using the XMLHttpRequest object.
Mozilla's spec provides links and stuff which will show you how to use it
and w3schools is a good resource.
Then it's all comes down to editing the page directly
element.removeChild(element.lastChild);
element.appendAdjacentHTML('beforeend',xhr.responseText);
How do u greayout backbutton or view source of browser so users can't click backbutton and view source code because javascript contains lot of business logic code. I need to greayout those options so users can't be able to click them. i recently joined banking project and i am beginner in java and development.
Try adding this in the Head section of your html file:
<script type="text/javascript">
window.history.forward();
function noGoingBack() {
window.history.forward();
}
</script>
And add this in your Body section:
<body onload="noGoingBack();" onpageshow="if (event.persisted) noBack();" onunload="">
This prevents the page from going back.
I have a javascript kind of feed, its more like a widget which displays dynamic content (that content is syndicated from other site).
This is what I have:
<div id="previewWidget"></div>
<script type="text/javascript" src="https://api.something/hlwidgetcommon.js">
<script type="text/javascript" src="https://api.something/hlwidgetcommon.js"></script>
<script type="text/javascript" src="http://api.something/latestDiscussion.js"></script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
hl.latestDiscussion('previewWidget', {
discussionKey:'d06c3624-210e3-4a2b-a303-003f7ed66e038', <---------- random letters
maxToRetrieve:'3',
subjectLength:'50',
contentLength:'160',
moreUrl:'https://www.something.com',
showLoginStatus:'0',
loginUrl:'https://www.something.com',
domainUrl:'https://www.something.com',
cbUseBioBubble:'0',
includeStaff:'1',
HLIAMKey:'d06c3624-210e3-4a2b-a303-003f7ed66e038' <---------- more random letters
});
});
</script>
(http://www.pastebin.ca/3030247)
What I would like to do is that each link that feed generates is opened in a new tab.
There is no <a href="#"> for me to go and add target=_blank.
Example:
This is what the feed generates (its a forum feed):
http://imgur.com/iQ45OtK
Probably the easiest solution: if you have any <a> elements within your feed, then you can easily give them target="_blank" via JS. If using jQuery, you might use this bit of JS, for instance:
$("#previewWidget a[href]").each(function() {
$(this).attr("target","_blank");
});
If you are looking to scan the text of each post for URLs, then you could wrap those URLs with <a target="_blank"> elements. For more info, see this post, as it's a bit complicated to detect URLs accurately with JS.
Unfortunately, opening links in a new tab using Javascript is unreliable because this comes down to browser configuration issues - often you will be caught in a pop-up blocker. See this post for more detail.
I'm building a website in php which can be used as ipad app.
When you place a website into the start window of a ipad you receive a sort of "fake" app.
I used this script to open links in the same window because when you don't use this, safari is going to open a new tab.
<script type="application/javascript">
$(document).ready(function() {
$('a').click(function(event) {
event.preventDefault();
window.location.assign($(this).attr('href'));
});
});
</script>
This works fine for all my a href's generated in html like .... But for my links in php echo "<a href='....'>" . "'....'" . "</a>", it doesn't work. Does anybody know how to fix this?
(Answer from original poster moved from his question to an answer here.)
Problem solved with adding the following code above the script paragraph:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
I can't get javascript to work with Twitter's Bootstrap.
I've got this
<p>
<a href="#" rel="tooltip" title="first tooltip" id="example">
hover over me
</a>
</p>
And I want it to appear as a tooltip.
It won't work, so I added this inside the HEAD:
<script type="text/javascript">
window.onload = function()
{
if(!window.jQuery)
{
alert('jQuery not loaded');
}
else
{
$(document).ready(function(){
$('#example').tooltip({'placement':'top', 'trigger' : 'hover'});
});
}
}
Noting thta it still wasn't working, I've deleted all script reference inside the page and added only this inseide the HEAD:
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="https://github.com/twitter/bootstrap/blob/master/js/bootstrap-tooltip.js"></script>
I´m not calling any particular file that I've downloadad, but hotlinking the original ones, and still the tooltip won't appear.
Note: I´m trying to set a new Drupal theme, so my site is inside Drupal (and the page is a tpl.php file).
Thanks for your insight!!
If you're wanting to use github files directly you need to use the raw, so you should point at https://raw.github.com/twitter/bootstrap/master/js/bootstrap-tooltip.js not https://github.com/twitter/bootstrap/blob/master/js/bootstrap-tooltip.js