有没有办法将片段附加到当前URL

时间:2015-05-03 07:58:39

标签: javascript php url

我对PHP比较陌生,我想知道是否有可能用PHP中的服务器上的 #something 修改当前的URL(或者我猜另一种语言;也许是JavaScript)?

感谢您的帮助,

abarnybox

2 个答案:

答案 0 :(得分:1)

使用javascript

Intent myIntent = new Intent(getActivity(), MyReceiver.class);
if(PendingIntent.getBroadcast(getActivity(), 0, myIntent, PendingIntent.FLAG_NO_CREATE) == null){
    pendingIntent = PendingIntent.getBroadcast(getActivity(), 0, myIntent,0);
    alarmManager = (AlarmManager)getActivity().getSystemService(Context.ALARM_SERVICE);
    alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent);
}

用php

window.location=window.location+'#something'

答案 1 :(得分:1)

使用当前网址

添加#something的另一种最简单方法

JS:

var e = "something";
     window.history.pushState(" ", "", "#" + e)