I have mathjax rendering problem, Mathjax shown perfectly in html but when I put it as php variable it doesnt work well.
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript" src="beeadmin/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
</script>
<!-- script untuk refresh/reload mathjax setiap content baru !-->
This is HTML<br>
Will Share \(\frac{4}{5}\) to others
<br><br>
<?php
$var1 = "<br>This is PHP<br>
Will Share \(\frac{4}{5}\) to others.";
?>
<?= $var1 ?>
Thats my code, well I want to have second render as well as the first (html) one. Kindly note I also want the formula shown inline. Thanks
Related
I want to use the html Content generated by TinyMCE in a Bootstrap environment, but Bootstrap is overwirting the styles given from the TinyMCE editor.
is there a way to disable all bootstrap classes within a "<div>" ?
I remember having the same issue in the same context. Here is my code
JavaScript
<script type="text/javascript">
tinymce.init({
selector: "textarea#myarea"
});
</script>
HTML
<div class="row">
<div class="span8">
<textarea id="myarea" name="myarea"><?php echo(stripslashes(html_entity_decode($myarea))); ?></textarea>
</div>
PHP : once the text has been typed, I submit it via PHP and it goes through these functions before being saved in a database.
htmlspecialchars($myarea);
trim($myarea);
addslashes($myarea);
Send some code if you'd like a more customed answer though.
I have a series of pages that load a navbar from an external HTML file like so:
<head>
<script>
$(function() {
$("#navbar").load("navbar.html");
});
</script>
</head>
<body>
<div id="navbar"></div>
<!--other stuff here-->
This is all in a PHP page. However, there's part of that navbar that I want to set to set to a PHP $_SESSION variable (a username). Is there a way to easily do this?
Consider change navbar.html to navbar.php, then replace the username part by:
<?php echo($_SESSION["username"] ?>
then
$("#navbar").load("navbar.php");
You won't be able to do it in the HTML you are including of course, but you could echo it out in your PHP page in a known element:
<span class='echoedUsername'><?php echo($_SESSION["username"] ?></span>
and then apply it to an element in your navbar:
$("#navbar .username").text($('.echoedUsername').text())
I am trying to hide a comment form on my wordpress blog (although the page isn't the wordpress blog, I just get the posts).
If I have comments then the hide/show will work for the form and for the comments. If I have no comments the function doesn't work and i'm not sure why.
If anybody can help I can upload the php files that show the posts (blog.php) and the comments page (comments.php) that is generated within the wordpress theme.
EDIT: PHP code removed as not relevant to error. Relevant HTML code as follows:
...
<body class="home blog logged-in custom-background">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#content img").addClass("imageSeven");
});
</script>
...
<a id="replytitle" href="javascript:togglecommentform('replyform17');">Show Comment Form</a>
<div id="replyform17" style="display:block;">
...
</div>
...
<a id="replytitle" href="javascript:togglecommentform('replyform6');">Show Comment Form</a>
<div id="replyform6" style="display:block;">
...
</div>
...
You have a problem, in that the output (view source) has a reference to jQuery right at the top:
<body class="home blog logged-in custom-background">
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("#content img").addClass("imageSeven");
});
</script>
Some points on this:
Because you don't include a reference to jQuery anywhere - this will cause an error, meaning that even if the rest of you JavaScript is valid, it will fail to run.
You don't need jQuery(document).ready... if you move all your JavaScript to the bottom of the page (just before the </body> end tag.)
Your main problem seems to be a confused code structure. Based on the messy code you have (no offense), I would recommend using a library like jQuery:
Step 1: Remove all the JavaScript you have in that page.
By the looks of things, that just means the <script> block thats right beneath your <body> tag.
Step 2: Replace these <a> start tags:
<a id="replytitle" href="javascript:togglecommentform('replyform17');">
<a id="replytitle" href="javascript:togglecommentform('replyform6');">
With these:
<a id="replytitle17" href="#">
<a id="replytitle6" href="#">
Step 3: Just before the </body> tag, include the following:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
var images = $('#content img');
if (images.length > 0) { images.addClass("imageSeven"); }
$('#replytitle17').click(function() { $('#replyform17').toggle(); });
$('#replytitle6').click(function() { $('#replyform6').toggle(); });
</script>
This should achieve everything your page has, in jQuery.
I'm attempting to use embedded code from a page within my server, the problem is that when I also try to add URL links to my Facebook below it they're not working?
I'm using this code which was successfully implemented. I'm not sure if the links I'm adding is hidden behind the image, but if it is I'm not sure how to get the link to show on top of the background image.
<body>
<img src="images/background.jpg" alt="" id="background" />
Facebook Link
<div rel="00000000" class="lrdiscoverwidget" data-logo="on" data-background="off" data-share-url="www.domain.com" data-css="">
<script type="text/javascript" src="http://launchrock-ignition.s3.amazonaws.com/ignition.1.1.js"></script>
</div>
<script type="text/javascript">
$(window).load(function() {
$("#background").fullBg();
});
</script>
</body>
Thank you!
For the last few days I am wandering arround the web for a script which would have the elementss I wish for.. The best thusfar is this one http://www.queness.com/post/328/a-simple-ajax-driven-website-with-jqueryphp, but there are a lot problems, where i need better solution:
I want no hashtags: I want all links for loading pages like folder (www.site.com/first/site/). This works magicaly on github (click here https://github.com/spjoe/deluge-yarss-plugin, and click on a random file and go back while watching adress bar). If someone knew what or how are they doing it would be really cool.
I need dynamic content: The script above only loads "cases" from switch function, while I need the php to check the url and find a file in mysql database and echo out content from desired tables based on the url, if it is found in the db ofcourse (if I point a link to site.com/harvey the php should find Harvey in the db and display for example his phone, adress and other details, while this must not be preloaded but requested only on click due to bandwight issues).
History: I would like to have an option where back and forward movements on the site would work flawlessly and with the animation as it works while clicking links..
Working links inside changable div: Because there is a problem with some scripts which don't change content where the link is inside it (for example first content box includes navigation, which should be replaced with different navigation in the second box), again this work very well with github..
I hope you give me some links or even more help with some code..
I think the script you are looking for is pjax, it has exactly all the features you want. You can find it on github: https://github.com/defunkt/jquery-pjax/tree/heroku
EDIT
You can use it with any server-side language you like. For example,
<script src="jquery.js"></script>
<script src="jquery.cookie.js"></script>
<script src="jquery.pjax.js"></script>
<script type="text/javascript">
$(function(){
$('nav a').pjax('#content')
})
</script>
in your website's head,
<nav>
<a href="otherContent1.php" >click me for other content</a>
<a href="otherContent2.php" >click me for even more additional content</a>
</nav>
<section id="content">
<h1>Original Content</h2>
<p>
this will be replaced by pjax with the content's of otherContent1.php or otherContent2.php
</p>
</section>
in your main template and modify your php code so that it looks for the HTTP_X_PJAX header. If it's present (see xhr.setRequestHeader('X-PJAX', 'true')) render only the part that should replace the contents of <section id="content">, else render the whole page. Pjax is then intelligent enough that if it works, it will replace only the contents of <section id="content">, and if it doesn't work, you still have regular links working. pjax will even take care of google analytics, if you're using it, so your tracking is still working.
EDIT2: Example
Ok, here you have a sample php page. be aware that I did not test this, i just wrote it quick and dirty here on stack overflow to show how you could solve this. This code is untested and certainly not production ready. But as an example, you could do something like this (the file should be named index.php):
<?php
$render_template=true;
if ($_SERVER["HTTP_X_PJAX"])
{
$render_template=false;
}
?>
<?php
if ($render_template) {
?>
<html>
<head>
<meta charset="utf-8" />
<title>Testing Pjax</title>
<script src="jquery.js"></script>
<script src="jquery.cookie.js"></script>
<script src="jquery.pjax.js"></script>
<script type="text/javascript">
$(function(){
$('nav a').pjax('#content')
})
</script>
</head>
<body>
Date in template: <?php echo $today = date("D M j G:i:s T Y"); ?>
<nav>
<a href="index.php?content=1" >click me for other content</a>
<a href="index.php?content=2" >click me for even more additional content</a>
</nav>
<section id="content">
<?php
}
?>
<?php
if ($_Get["content"]==1)
{
?>
<h1>Content=1</h1>
Date in content: <?php echo $today = date("D M j G:i:s T Y"); ?>
<p>
this will be replaced by pjax with the content's of index.php?content=1 or index.php?content=2
</p>
<?php
} else {
?>
<h1>Content 2=2</h1>
Date in content: <?php echo $today = date("D M j G:i:s T Y"); ?>
<p>
this will be replaced by pjax with the content's of index.php?content=1 or index.php?content=2
</p>
<?php
}
?>
<?php
if ($render_template) {
?>
</section>
</body>
</html>
<?php
}
?>
If you want the URL to display the "Correct" url when you ajax a page request you can use PJAX it changes the history with pushState but it doesn't work on ie6-ie9 check out CanIUse: History for compatibility issues.