Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript open in a new window or tab.

Status
Not open for further replies.

vvomble

Programmer
Dec 5, 2011
8
Hi me again lol.

i got a calender widget off motigo and every time i click a date it takes me away from my site and the only way back is to click back button is there anything in this code i can do to make it when a person clicks a date the redirect happens in a new tab?

Code:
<script type="text/javascript">
  var motigo_monthview_months = 3;
  var motigo_monthview_frame_width = 150;
  var motigo_monthview_frame_height = 450;
  var motigo_calendar_id = 35590;
  var motigo_calendar_token = "433d0d0d3c4815b";
</script>
<script type="text/javascript" src="[URL unfurl="true"]http://35590.calendars.motigo.com/js/calendar/month_view.js"></script>[/URL]

thanks in advance
 
Hi

Not really. The [tt]target[/tt] is hardcoded in calendar.js's line 63 as :
Code:
[COLOR=silver gray] 63 [/color]   html    [teal]+=[/teal] events_by_date[teal][[/teal]dbDate[teal]][/teal] [teal]!=[/teal] undefined [teal]?[/teal] [green][i]'<a [highlight]target="_top"[/highlight] href="/day/show/date/'[/i][/green][teal]+[/teal] dbDate [teal]+[/teal] [green][i]'">'[/i][/green][teal]+[/teal]incrementingDate[teal].[/teal][COLOR=darkgoldenrod]getDate[/color][teal]()[/teal] [teal]+[/teal] [green][i]'</a>'[/i][/green] [teal]:[/teal] incrementingDate[teal].[/teal][COLOR=darkgoldenrod]getDate[/color][teal]();[/teal]
However if you can interact with that document after it gets rendered, the following code will change the [tt]target[/tt]s :
JavaScript:
$$[teal]([/teal][green][i]'a[target="_top"]'[/i][/green][teal]).[/teal][COLOR=darkgoldenrod]each[/color][teal]([/teal][b]function[/b][teal]([/teal]a[teal])[/teal][teal]{[/teal]a[teal].[/teal]target[teal]=[/teal][green][i]'_blank'[/i][/green][teal]}[/teal][teal])[/teal]
But as far as I can tell, you have no chance. That document is loaded in an [tt]iframe[/tt] directly from their server, so the browsers will deny the access to it for your scripts.


Feherke.
 
thanks I've emailed them what you've said to see if they are willing to implement it because it's not great the way it is now
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top