Using Get Element By ID - class

I'm trying to set/add a class name to a div by targeting its ID but I'm not having much success at the minute.
I basically have my website navigation saved to an external file so all I need to do is make changes to one file to update all pages, but doing this restricts my website users from being able to easily identify which page of the site they are on.
I have a class="current" option that visually tells the user where they are in the menu but I can't for the life of me add the class to the navigation menu. I'm trying to run the code after the nav menu file is loaded in using the following code, where am I going wrong?
<?php include_once ("includes/page_top.php"); ?>
<script type="text/javascript">
document.getElementById('home').className("current");
</script>

className isn't a function.
Instead of this:
document.getElementById('home').className("current");
You want this:
document.getElementById('home').className = "current";

Related

Why can't I see script injected using GWT ScriptInjector?

I'm trying out using GWT's ScriptInjector for the first time, and was wondering why I can't see the injected script as a tag anywhere in the page when I view page source. I'd expect it to show up in the page head.
I'm using a dead simple example, which works in that it displays the alert. I'm just wondering why I can't physically see it injected in the page. Also if I declare a JavaScript variable inside my script, it doesn't seem available on the global scope.
ScriptInjector.fromString("window.alert('testing');")
.setWindow(ScriptInjector.TOP_WINDOW)
.inject();
ScriptInjector works by injecting your js snippet into the top level window object and, by default, remove it just after it got evaluated (if you used fromString(); with fromUrl() the element is not removed by default). This is why you do not see it, but it actually executes.
If you want to keep the injected script element, just use setRemoveTag(false) on your builder FromString object, i.e.:
ScriptInjector.fromString("window.alert('testing');")
.setRemoveTag(false)
.setWindow(ScriptInjector.TOP_WINDOW)
.inject();
Please have a look at below sample.
I have modified the inner HTML of a div. The changes are visible in Firebug but if you view the source it will be not there.
EntryPointClass:
ScriptInjector.fromString("document.getElementById('mydiv').innerHTML='hi';")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
HTML:
<html>
...
<body>
<div id='mydiv'></div>
</body>
...
</html>
Snapshot:
View Source:

inserting content of one template inside another umbraco

Im new to umbraco. im trying to display certain section of one template inside another template.
for e.g.
1) i have Product page, which lists all the products and few description about them.
2) now i want to show this content to my home page also. i dont want to copy and paste code from product page to home page..as this would require me to do the same if some changes come on product page.
Also, Product page contains child nodes, which automatically displayed by Macro.
i just want to display Product page contents to my home page.
Thanks in advance.
You simply need to add a new macro that will display the product page contents you need and then add it into the homepage template.
Doing it as a razor scripting file would be something like (where 1111 is your product page node id). If you use ucomponents you could use uQuery.getNodeByUrl or some other nicer helper method, but this code should work out of the box:
var productPage = #Model.NodeById(1111);
<div>
<a href="#productPage.Url">
<h4>
#productPage.copyHeadline
</h4>
</a>
#if (!string.IsNullOrEmpty (#productPage.copyBlurb.ToString ()))
{
#Html.Raw(#productPage.copyBlurb.ToString().Substring(0, 200) + "...");
}
</div>

how can show silder look when navigate one html page another in phonegap?

Right now I am developing PhoneGap app all functionality are successfully done which what client need but in my PhoneGap app I am using multiple html pages on click of one button index.html it will naviagte to another html but client need silder look when naviagte one page to another page..
Code is:
<li><a onclick="callFestvialinfo()"><img src="images/festival_info_button.png" width="123" height="123" alt="" /></a></li>
function callFestvialinfo()
{
window.location = "festival_info.html";
}
it will navigate festival_info.html normally but client need silder look from index to festival_info.html and festival_info.html to index when onclick back.
You can check this out. A very light weight solution to page transitions.
http://www.fasw.ws/faswwp/non-jquery-page-transitions-lightweight/

Zend Framework: Saving complete page to a file

I need to add the main navigation/header from my Zend based site onto the top of a third party product. The third party product will allow me to include any file(s) on the server into their layouts. My thought was I would run a cron that would save the header part of my Zend layout to a hard coded html file each night. Then just read in the appropriate file on the third part.
So I tried:
$htmlcontent = $this->view->render('file.phtml');
then saving $htmlcontent to a file. It saves out everything from file.phtml correctly but excludes the layout/header, which the part I really need. How would I go about saving everything generated ( including layout) to a file.
thanks
summer
The view script is just a part of the whole layout. In a normal Zend Framework setup, you will have one layout in which your view scripts (eg, file.phtml) in your case. The layout file will look like this:
<html>
<body>
<div>My header here</div>
<?php echo $this->layout()->content; ?>
<div>I have a footer here.</div>
</body>
</html>
$this->layout()->content will hold your view script, according to the page you are in (eg, file.phtml when your call fileAction()).
So, to access the full HTML of your page, you have two options:
Use the good old file_get_contents and get the complete rendered HTML to a string with http request.
$htmlcontent = file_get_contents('http://yourdomain/index/file');
Get the layout instance of the Zend Framework, assign content to it, and render it to a string as follows:
$layout = $this->_helper->layout->getLayoutInstance();
$layout->content = $this->view->render('file.phtml');
$htmlcontent = $layout->render();

Tab in Zend Framework?

I am making a social website that each user can view his own or other user's profile. I created a user controller to handle the identity and blog, status, profile controller to retrieve information. My question is how can I make the three sub controllers ( blog, status, profile) under the user controller, like a tab view?
If you want to have Tabs in your application you should pick first an ajax framework to create andload content into them:
Assuming you are willing to use jquery:
Tabs supports loading tab content via Ajax in an unobtrusive manner.
The HTML you need is slightly different from the one that is used for static tabs: A list of links pointing to existing resources (from where the content gets loaded) and no additional containers at all (unobtrusive!). The containers' markup is going to be created on the fly:
<div id="example">
<ul>
<li><span>USER</span></li>
<li><span>his blogs</span></li>
<li><span>Whatever</span></li>
</ul>
</div>
For more info: http://jqueryui.com/demos/tabs/#Events
And the tab content will be loaded through those "controllers" which are in fact generating view scripts.
To disable the layout on your views which should be integrated inside the Tabs-panels, if the mode is simple, you can add in ZF1
$this->_helper->layout()->disableLayout();