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>
Related
I have a problem when I use the network of my professional offices: when I do a Google search in private browsing, it systematically asks for a long and anoying captcha.
I found a solution that works: launch 3 occurrences of my search (in 3 tabs). The 3rd occurrence is displayed normally, without captcha request.
So, I would like to develop a PHP page that will open 2 new tabs with my search, then will close these 2 tabs after a timeout and at the end of this timeout will redirect my 1st tab to the Google search page.
Here is the code of my page. The problem is that it works perfectly if my redirection URL is not the search page. The script below works perfectly if I put "http://www.google.com" as my redirection address. However, if I put "http://www.google.com/search?q=mysearch" the two tabs do not close.
Here is my code:
<html>
<head>
<title>Redirect...</title>
<script language="javascript" type="text/javascript">
var url = "https://www.google.com/?q=".<?php echo $_GET['q']; ?>";
var google = window.open(url);
setTimeout(function(){google.close()}, 1000);
var googleb = window.open(url);
setTimeout(function(){googleb.close()}, 1500);
</script>
</head>
<body style="background-color:#202124">
<script>
setTimeout(function(){
window.location.href = 'https://www.google.com/search?q=<?php echo $_GET['q']; ?>';
}, 2000);
</script>
</html>
Do you see anything that prevents tabs from closing when I use a URL with this structure: "https://www.google.com/search?q=mysearch"?
I tried to replace the URL of the type "https://www.google.com/search?q=mysearch"?
by a simpler URL like "https://www.google.com" and it works
Many thanks for your help!
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 got a JS problem, I want to excute a JS function after the whole page shown,the struct of the page such as:
<iframe id="i_frame" src="xxx.jsp"></iframe>
and the JS included in the xx.jsp:
...
<head>
...
<script type="text/javascript" src="yy.js"></script>
</head>
yy.js:
$(document).ready(function() {
var i_fram = $(window.parent.document).find('[id="i_frame"]');
$(i_fram).load(function() {
alert('trigger!');
});
});
this works well on PC(chrome), but on Iphone4s(IOS8.1, Safari), the alert trigger befor the page completely shown, even it alert befor the bottom-half of the page shown.I'd tried:"http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_ev_onpageshow", it still has this problem.
Is there something different between Safari's renderer and other browsers?
I'm importing an external js file right after the opening body
<body>
<script src="http://website.com/jsfile#1"></script>
etc...
</body>
the head includes the following:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.2/jquery.mobile.min.css" /><script src="//ajax.googleapis.com/ajax/libs/jquerymobile/1.4.2/jquery.mobile.min.js"></script>
the script file looks like this:
$(document).ready(function() {
$(document).on('click', ".clickable", function() {
var o_id = $(this).attr('id');
$('#l_id').val(o_id);
$("#pick_location").attr("action", "pick_contact.php?l_id=" + o_id + "&p_id=" + $('#p_id').attr('value') + "&f_id=" + $('#f_id').attr('value'));
$('#pick_location').submit();
});
});
later I dynamically created clickable divs that trigger the script, e.g.
<?php
echo '<div id ="'.$id.'" class="clickable"><div>test</div></div>';
?>
clicking submits the form and it takes the user to another page very similar again where the user can pretty much do exactly the same thing (the application has to do with selecting stuff in one page, then more stuff in next, etc) as before but with a different script
<script src="jsfile#2"></script>
the problem I'm having is that in that second page the clicked div is triggering the js file jsfile#1 instead of the jsfile#2. So, this caching is giving me a headache. Same results in latest Chrome and Firefox. Can't seem to find anything that works for my problem. Any suggestions would be greatly appreciated
I have a javascript widget that can be inserted on an a plain-old html page like this:
<html>
<head>
<script type='text/javascript' src="http://example.com/widget.js"></script>
</head>
<body>
<script type='text/javascript'>
//<![CDATA[
try{ widget_constructor('key',500,400); }
catch(e){ alert(e.message); }
//]]>
</script>
</body>
</html>
I would like to insert this javascript on one page of a Drupal 6 site (not every page).
This is what I have tried so far to get the script tag in the HEAD:
I set the Full HTML input format to allow php.
For the Drupal page, I set the input format to Full HTML
I then added this to the top of the body of my Drupal page:
<?php
drupal_set_html_head('<script type="text/javascript" src="http://example.com/widget.js"> </script>');
?>
But Drupal doesn't parse the php and instead prints this at the top of the page:
<?php drupal_set_html_head(''); ?>
Any suggestions as to how I can do this?
#Jeff: You should not really reconsider that. Using the PHP Filter is generally a bad idea as it potentially opens security holes. (In case someone would gain access to your user account or you have a misconfiguration in your settings this is a direct path to compromising the whole server)
I would rather propose to add js via the template.php of your theme. Also the right method to use is drupal_add_js with the option inline:
http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_js/6
Here are some further reads on how to use it:
http://drupal.org/node/304178#comment-1000798 http://drupal.org/node/482542
I'm not too familiar with Drupal so this answer merely gets around your widget not loading without actually answering the question why that PHP block isn't being parsed as PHP.
You don't need to call the <script> tag inside the <head>. You can just place that line right above the <script> tag that calls the widget constructor.
<html>
<head>
</head>
<body>
<script type='text/javascript' src="http://example.com/widget.js"></script>
<script type='text/javascript'>
//<![CDATA[
try{ widget_constructor('key',500,400); }
catch(e){ alert(e.message); }
//]]>
</script>
</body>
</html>
After writing that all out, I figured out the problem...
The full html input format has an HTML corrector filter turned on by default, and that filter appears to have caused problems with the PHP code. Reordering the filters to put the PHP evaluator first fixed the problem.