I hope you are using CRM 2011, try like :
if (window.parent && window.parent.Xrm.Page.getAttribute("name").getValue()!=null) {
alert(window.parent.Xrm.Page.getAttribute("name").getValue());
}
Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
Vikram !